source: rtos_arduino/trunk/arduino_lib/libraries/TFT/examples/Esplora/EsploraTFTColorPicker/EsploraTFTColorPicker.ino@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 1.2 KB
RevLine 
[136]1/*
2
3 Esplora TFT Color Picker
4
5 This example for the Esplora with an Arduino TFT reads
6 the input of the joystick and slider, using the values
7 to change the screen's color.
8
9 This example code is in the public domain.
10
11 Created 15 April 2013 by Scott Fitzgerald
12
13 http://arduino.cc/en/Tutorial/TFTColorPicker
14
15 */
16
17#include <Esplora.h>
18#include <TFT.h> // Arduino LCD library
19#include <SPI.h>
20
21void setup() {
22 Serial.begin(9600);
23
24 // initialize the LCD
25 EsploraTFT.begin();
26
27 // start out with a white screen
28 EsploraTFT.background(255, 255, 255);
29
30}
31
32void loop() {
33
34 // map the values from sensors
35 int xValue = map(Esplora.readJoystickX(), -512, 512, 0, 255); // read the joystick's X position
36 int yValue = map(Esplora.readJoystickY(), -512, 512, 0, 255); // read the joystick's Y position
37 int slider = map(Esplora.readSlider(), 0, 1023, 0, 255); // read the slider's position
38
39 // change the background color based on the mapped values
40 EsploraTFT.background(xValue, yValue, slider);
41
42 // print the mapped values to the Serial monitor
43 Serial.print("background(");
44 Serial.print(xValue);
45 Serial.print(" , ");
46 Serial.print(yValue);
47 Serial.print(" , ");
48 Serial.print(slider);
49 Serial.println(")");
50
51 delay(33);
52
53}
54
Note: See TracBrowser for help on using the repository browser.