I just purchased a few of these displays through Amazon.com. I initially had quite a few problems with this display since I was using MakerFocus instructions to use the code from the YouTube link on the product page. I finally realized that the included libs were outdated and buggy so I deleted them and got the libs used fresh from github. Here is my code that works fine with this display (link included in the code). This is only a text example with a Joystick, I've added code comments as if I am explaining the whole process to the best of my ability.
BTW: this is my first code with the Arduino Uno. I am surprised at how easy it is to code for this platform. I've also never programmed in c, but the included, and online, help is excellent and to the point!
EDIT: I found a great graphics library for this display on Instructables the library download link is here. You need to modify one line 21 with your pinouts, I am using the same pinout as my code here. If you have it connected the same as my code, the line should read:
UTFT myGLCD(ST7735,11,13,10,9,8);
Below is my code for a text only example.
/***************************************************
Copyright 2018 Jorge Joaquin Pareja
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without
limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*****************************************************************************************************
This code is for the 1.44" TFT LCD Module https://www.amazon.com/gp/product/B07B4BDWCL/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1
using Adafruit’s current libraries pulled fresh from github, ignore the products linked video since the links included in the
video have some older code that causes errors on this screen.
Pinning:
These budget displays have what seem to be a misprinted silkscreen text that at first sight, one
will think these are I2C, they are not, they are in fact SPI. WIre them as follows:
* 5V to +5V
* GND to GND
* GND to GND
* NC
* NC
* LED to 5V
* SCL to Digital 13
* SDA to Digital 11
* RS to Digital 8
* RST to Digital 9
* CS to Digital 10
Joystick:
* ARef to +5 (for Joystick reading)
* A0 to Joystick X
* A1 to Joystick Y
* Voltage connections for your Joystick
****************************************************/
#define F_CPU 20000000UL // 20 MHz
// Adafruit
#include <Adafruit_GFX.h> // Core graphics library ( https://github.com/adafruit/Adafruit-GFX-Library )
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735 ( https://github.com/adafruit/Adafruit-ST7735-Library )
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789 ( same as ST7735 files)
// Arduino Included Libs
#include <SPI.h>
#define TFT_CS 10 // Silkscreen label CS
#define TFT_RST 9 // Silkscreen label RST
#define TFT_DC 8 // Silkscreen label RS
//#define TFT_SCLK 13 // Silkscreen label SCL (Needs to be Connected even if this line is commented)
//#define TFT_MOSI 11 // Silkscreen label SDA (Needs to be Connected even if this line is commented)
// For 1.44" TFT with ST7735 use
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
// Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST); // must use this line if you want software SPI and define CLK and MOSI above
// i is used to just keep track of loop counts and display it on the screen
int i = 0;
// Padding in pixels, incase font is slightly off screen
int cpadding = 0; // column padding
int rpadding = 2; // row/line padding
// 21 Columns on a 1.44 (128x128) display. I use this for calculating the
// columns for text placement using setCursor
int tft144Col[] = {cpadding+0, // col 0
cpadding+(1*6), // col 1
cpadding+(2*6), // col 2
cpadding+(3*6), // col 3
cpadding+(4*6), // col 4
cpadding+(5*6), // col 5
cpadding+(6*6), // col 6
cpadding+(7*6), // col 7
cpadding+(8*6), // col 8
cpadding+(9*6), // col 9
cpadding+(10*6), // col 10
cpadding+(11*6), // col 11
cpadding+(12*6), // col 12
cpadding+(13*6), // col 13
cpadding+(14*6), // col 14
cpadding+(15*6), // col 15
cpadding+(16*6), // col 16
cpadding+(17*6), // col 17
cpadding+(18*6), // col 18
cpadding+(19*6), // col 19
cpadding+(20*6)}; // col 20
// 16 Rows on a 1.44 (128x128) display.
int tft144Row[] = { rpadding+(0*8), // line 00
rpadding+(1*8), // line 01
rpadding+(2*8), // line 02
rpadding+(3*8), // line 03
rpadding+(4*8), // line 04
rpadding+(5*8), // line 05
rpadding+(6*8), // line 06
rpadding+(7*8), // line 07
rpadding+(8*8), // line 08
rpadding+(9*8), // line 09
rpadding+(10*8), // line 10
rpadding+(11*8), // line 11
rpadding+(12*8), // line 12
rpadding+(13*8), // line 13
rpadding+(14*8), // line 14
rpadding+(15*8)}; // line 15
// hopefully saves program space
String strLine = "Line ";
// A joystick is connected to A0 and A1
int jsX;
int jsY;
void setup(void) {
// Use this initializer for a 1.44" TFT
tft.initR(INITR_144GREENTAB); // initialize a ST7735S chip
// fill the screen with a black background
tft.fillScreen(ST77XX_BLACK);
// set the text color, and the background color so that new text will cover over any old text
// without having to blank the entire screen
tft.setTextColor(ST77XX_WHITE, ST77XX_BLACK); // white text on black background, prevents having to redraw the entire screen
tft.setTextWrap(false); // disable wrapping of text
analogReference(EXTERNAL); // Connect +5V to ARef externaly
pinMode(A0, INPUT); // Joystick X
pinMode(A1, INPUT); // Joystick Y
delay(1000); // wait one second
}
void loop() {
jsX = analogRead(A0);
jsY = analogRead(A1);
pl(strLine+"00", 0, 0);
pl("012345678901234567890", 1, 0);
pl("L", 2, 10);
pl("TTTTTTTTTTTTTTTTTTTTT", 3, 0);
pl("i = ", 4, 0);
tft.print(i, DEC);
pl(" ", 5, 12); // needed to cover up previous reading digits
pl("Joystick X: ", 5, 0);
tft.print(jsX, DEC);
pl(" ", 6, 12); // needed to cover up previous reading digits
pl("Joystick Y: ", 6, 0);
tft.print(jsY, DEC);
pl(strLine+"08", 7, 0);
pl(strLine+"09", 8, 0);
pl(strLine+"10", 9, 0);
pl(strLine+"11", 10, 0);
pl(strLine+"12", 11, 0);
pl(strLine+"13", 12, 0);
pl(strLine+"14", 13, 0);
pl(strLine+"15", 14, 0);
pl(strLine+"16", 15, 0);
i++; // lets me see how fast screen can update
}
/*
* print string based on the line and column numbers, calculated in the arrays
*/
void pl(String txt, int lineNumber, int columnNumber){
tft.setCursor(tft144Col[columnNumber], tft144Row[lineNumber]);
tft.print(txt);
}