aboutsummaryrefslogtreecommitdiff
path: root/libraries/TFT/examples/Arduino/TFTColorPicker
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2013-05-29 18:30:36 +0200
committerCristian Maglie <c.maglie@bug.st>2013-05-29 18:30:36 +0200
commitd90fcca5839d13d57ed527d4009b78d22dafbde7 (patch)
tree768b98af21e5075846184dd3de41ae0c22e75e20 /libraries/TFT/examples/Arduino/TFTColorPicker
parent7207108255a772474b322151cb0fd113e8030afe (diff)
parentef4e8c65373f531ce6d37ff226a21fc9b358ff29 (diff)
Merged 1.0.5
Diffstat (limited to 'libraries/TFT/examples/Arduino/TFTColorPicker')
-rw-r--r--libraries/TFT/examples/Arduino/TFTColorPicker/TFTColorPicker.ino67
1 files changed, 67 insertions, 0 deletions
diff --git a/libraries/TFT/examples/Arduino/TFTColorPicker/TFTColorPicker.ino b/libraries/TFT/examples/Arduino/TFTColorPicker/TFTColorPicker.ino
new file mode 100644
index 0000000..74fc176
--- /dev/null
+++ b/libraries/TFT/examples/Arduino/TFTColorPicker/TFTColorPicker.ino
@@ -0,0 +1,67 @@
+/*
+
+ TFT Color Picker
+
+ This example for the Arduino screen reads the input of
+ potentiometers or analog sensors attached to A0, A1,
+ and A2 and uses the values to change the screen's color.
+
+ This example code is in the public domain.
+
+ Created 15 April 2013 by Scott Fitzgerald
+
+ http://arduino.cc/en/Tutorial/TFTColorPicker
+
+ */
+
+// pin definition for the Uno
+#define cs 10
+#define dc 9
+#define rst 8
+
+// pin definition for the Leonardo
+// #define cs 7
+// #define dc 0
+// #define rst 1
+
+#include <TFT.h> // Arduino LCD library
+#include <SPI.h>
+
+TFT TFTscreen = TFT(cs, dc, rst);
+
+void setup() {
+ // begin serial communication
+ Serial.begin(9600);
+
+ // initialize the display
+ TFTscreen.begin();
+
+ // set the background to white
+ TFTscreen.background(255, 255, 255);
+
+}
+
+void loop() {
+
+ // read the values from your sensors and scale them to 0-255
+ int redVal = map(analogRead(A0), 0, 1023, 0, 255);
+ int greenVal = map(analogRead(A1), 0, 1023, 0, 255);
+ int blueVal = map(analogRead(A2), 0, 1023, 0, 255);
+
+ // draw the background based on the mapped values
+ TFTscreen.background(redVal, greenVal, blueVal);
+
+ // send the values to the serial monitor
+ Serial.print("background(");
+ Serial.print(redVal);
+ Serial.print(" , ");
+ Serial.print(greenVal);
+ Serial.print(" , ");
+ Serial.print(blueVal);
+ Serial.println(")");
+
+ // wait for a moment
+ delay(33);
+
+}
+