Examples > TFT
This example for the Arduino TFT screen reads the input of three analog sensors, using the values to change the screen's color.
Color on the TFT screen is handled as 8-bit numbers (0-255). However, the library scales these values to 5-bits (32 levels) for red and blue, 6-bits (64 levels) for green.
Connect power and ground to the breadboard.
Attach the three pots to the breadboard, connecting their outside legs to power and ground. the center legs should connect to A0-A2.
Connect the LCD screen to the breadboard. The headers on the side of the screen with the small blue tab and arrow should be the ones that attach to the board. Pay attention to the orientation of the screen, in these images, it is upside down.
Connect the BL and +5V pins to power, and GND to ground. Connect CS-LD to pin 10, DC to pin 9, RESET to pin 8, MOSI to pin 11, and SCK to pin 13. If you're using a Leonardo, you'll be using different pins. see the getting started page for more details.
To use the screen you must first include the SPI and TFT libraries.
Define the pins you're going to use for controlling the screen, and create an instance of the TFT library named
TFTscreen. You'll reference that object whenever you're working with the screen.
setup(), initialize the screen and clear the background. Start serial communication as well.
loop(), read the values fron the pots, mapping them to values between 0-255. with
background(), set the mapped background colors and print the values to the serial monitor.
The complete sketch is below :