Hardware Reference
In-Depth Information
9 #define DC 9
10 #define RST 8
11
12 int lightPos = 0;
13 int currentTemp = 1;
14
15 PImage backgroundIMG;
16
17 // Create an instance of the TFT library
18 TFT screen = TFT(TFT_CS, DC, RST);
19
20 // Char array for printing text on the screen
21 char tempPrintout[10];
22
23 void setup()
24 {
25 // Initialize the screen
26 screen.begin();
27
28 // TFT screen will first be used to output error messages
29 screen.stroke(255, 255, 255);
30 screen.background(0, 0, 0); // Erase the screen
31
32 // Initialize the SD card
33 if (!SD.begin(SD_CS))
34 {
35 screen.text("Error: Can't init SD card", 0, 0);
36 return;
37 }
38
39 // Load and print a background image
40 backgroundIMG = screen.loadImage("bg.bmp");
41 if (!backgroundIMG.isValid())
42 {
43 screen.text("Error: Can't open background image", 0, 0);
44 return;
45 }
46
47 // Now that the image is validated, display it
48 screen.image(backgroundIMG, 0, 0);
49
50 // Set the font size to 50 pixels high
51 screen.setTextSize(5);
52 }
53
54 void loop()
55 {
56
57 // Get a light reading
58 int lightLevel = map(analogRead(A1), 0, 1023, 0, 64);
59
Continues
Search WWH ::




Custom Search