1 | #include <TFT.h> // Arduino LCD library
|
2 | #include <SPI.h>
|
3 |
|
4 | // pin definitions for the Uno
|
5 | #define cs 10
|
6 | #define dc 7
|
7 | #define rst 8
|
8 |
|
9 | // pin definitions for the Leonardo
|
10 | // #define cs 7
|
11 | // #define dc 0
|
12 | // #define rst 1
|
13 |
|
14 | // create an instance of the library
|
15 | TFT TFTscreen = TFT(cs, dc, rst);
|
16 |
|
17 | // char array to print to the screen
|
18 | char sensorPrintout[4];
|
19 | char Wert = 1;
|
20 |
|
21 |
|
22 | void setup() {
|
23 |
|
24 | // Put this line at the beginning of every sketch that uses the GLCD:
|
25 | TFTscreen.begin();
|
26 |
|
27 | // clear the screen with a black background
|
28 | TFTscreen.background(0, 0, 0);
|
29 |
|
30 | // write the static text to the screen
|
31 | // set the font color to white
|
32 | TFTscreen.stroke(255, 255, 255);
|
33 | // set the font size
|
34 | TFTscreen.setTextSize(2);
|
35 | // write the text to the top left corner of the screen
|
36 | TFTscreen.text("Sensor Value :\n ", 0, 0);
|
37 | // set the font size very large for the loop
|
38 | TFTscreen.setTextSize(5);
|
39 | }
|
40 |
|
41 | void loop() {
|
42 |
|
43 | String sensorVal = String(Wert);
|
44 | sensorVal.toCharArray(sensorPrintout, 4);
|
45 |
|
46 |
|
47 | // set the font color
|
48 | TFTscreen.stroke(255, 255, 255);
|
49 | // print the sensor value
|
50 | TFTscreen.text(sensorPrintout, 0, 20);
|
51 | // wait for a moment
|
52 | delay(250);
|
53 | // erase the text you just wrote
|
54 | TFTscreen.stroke(0, 0, 0);
|
55 | TFTscreen.text(sensorPrintout, 0, 20);
|
56 | }
|