在合宙通信買了一個1.8寸的TFT屏,驅動芯片是ST7533,本來打算使用Air800直接驅動,但由於其他原因,放棄了。於是嘗試使用arduino驅動,為了屏幕刷新速度更快,采用硬件SPI。
硬件連接
屏幕引腳如下圖所示:
主要用到的引腳有:
GND:地
VCC:電源
SCL:時鍾
SDA:數據
RES:復位
DC:數據/命令選擇
CS:片選
分別對應arduino的以下引腳:
GND:地 —————— GND
VCC:電源 —————— VCC
SCL:時鍾 —————— SPI_SCL(D13)
SDA:數據 —————— SPI_MOSI(D11)
RES:復位 —————— D8
DC:數據/命令選擇 —————— D9
CS:片選 —————— D10
程序部分
下載以下兩個庫:Adafruit GFX 程序,Adafruit ST7735 程序庫,然后解壓到Arduino IDE安裝文件下的libraries文件夾下。
結果如下圖:
打開Adafruit_ST7735/examples/graphicstest/graphicstest.ino文件,根據上述引腳連接,修改以下代碼:
// For the breakout, you can use any 2 or 3 pins // These pins will also work for the 1.8" TFT shield #define TFT_CS 10 #define TFT_RST 8 // you can also connect this to the Arduino reset // in which case, set this #define pin to -1! #define TFT_DC 9 // Option 1 (recommended): must use the hardware SPI pins // (for UNO thats sclk = 13 and sid = 11) and pin 10 must be // an output. This is much faster - also required if you want // to use the microSD card (see the image drawing example) Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); // Option 2: use any pins but a little slower! #define TFT_SCLK 13 // set these to be whatever pins you like! #define TFT_MOSI 11 // set these to be whatever pins you like! //Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);