EsploraTFTColorPicker
Using the joystick and slider, change the color of the TFT screen.
Esplora TFT Color Picker
This example for the Esplora with an Arduino screen reads the input of the joystick's two axes and the slider, using the values to change the screen's color.
Color on the TFT screen 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.
Hardware Required
- Arduino Esplora 
- Arduino TFT screen 
Circuit
Attach the screen to the socket on your Esplora, with the label "SD Card" facing up.
Code
To use the screen you must first include the SPI and TFT libraries. Don't forget to include the Esplora library as well.
1#include <Esplora.h>2#include <GLCD.h>3#include <SPI.h>In
setup()1void setup() {2
3  Serial.begin(9600);4
5  EsploraTFT.begin();6
7  EsploraTFT.background(255, 255, 255);8}In
loop()background()1void loop() {2
3  int xValue = map(Esplora.readJoystickX(), -512, 512, 0, 255);4
5  int yValue = map(Esplora.readJoystickY(), -512, 512, 0, 255);6
7  int slider = map(Esplora.readSlider(), 0, 1023, 0, 255);8
9  EsploraTFT.background(xValue, yValue, slider);10
11  Serial.print("background(");12
13  Serial.print(xValue);14
15  Serial.print(" , ");16
17  Serial.print(yValue);18
19  Serial.print(" , ");20
21  Serial.print(slider);22
23  Serial.println(")");24
25  delay(33);26
27}The complete sketch is below :
1SORRY, There is an error at our code repository, please inform to web@arduino.ccSuggest changes
The content on docs.arduino.cc is facilitated through a public GitHub repository. If you see anything wrong, you can edit this page here.
License
The Arduino documentation is licensed under the Creative Commons Attribution-Share Alike 4.0 license.
