[TOC](Arduino 1.44寸st7735s TFT+SD卡显示图片)
硬件
硬件列表
硬件 | 数量 |
---|
Arduino UNO | 1 |
1.44寸 128*128 st7735s TFT屏 | 1 |
SD卡(我测试时使用的是8G tf卡 | 1 |
tf卡模块 | 1 |
硬件外观
Arduino UNO
1.44寸 128*128 st7735s TFT屏
TF卡模块
接线方式
TFT | arduino |
---|
GND | GND |
VCC | 5V |
BLK | D12 |
RST | D9 |
DC | D8 |
CS | D10 |
SCK | D13 |
SDA | D11 |
TF卡模块 | arduino |
---|
GND | GND |
VCC | 5V |
MISO | D12 |
MOSI | D11 |
SCK | D13 |
CS | D4 |
软件
取模设置
Arduino程序
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>
#include <SD.h>
#define TFT_CS 10
#define TFT_RST 9
#define TFT_DC 8
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
unsigned int k=0;
String fn = "1.bin";
void setup() {
Serial.begin(9600);
SD.begin(4);
tft.initR(INITR_144GREENTAB);
tft.fillScreen(ST77XX_BLACK);
showpic(0,0,128,87,fn);
}
void loop() {
}
void showpic(unsigned int x,unsigned y,unsigned int xe,unsigned int ye,String filename){
int i,j;
unsigned int p;
tft.setCursor(x, y);
File pic=SD.open(filename,FILE_READ);
while (pic.available()) {
for(i=y;i<ye;i++){
for(j=x;j<xe;j++){
p=pic.read()<<8|pic.read();
tft.fillRect(i,j,1,1,p);
}
}
}
pic.close();
}
最终效果图
PS:无论是arduino还是写文章我都是萌新,请各位大佬下手轻点。有问题欢迎指正。