im trying to make 4 LEDs turn on with my TFT touchscreen shield....
i have an arduino MEGA 2560 R3, and the touchscreen shield i have is from Seeedstudio: TFT 2.8" touchscreen sheild V1 (RED).
so far this is all i have, i just need to write the code to turn on the LEDs when i press each square, and this is where i need help.
i dont know how to do that, any of you guys can just help me making one square to work. after that ill just take a look at it and then i can make the other 3 to work.
this is the code i have:
Code: Select all
#include <stdint.h>
#include <TouchScreen.h>
#include <TFT.h>
#ifdef SEEEDUINO
#define YP A2 // must be an analog pin, use "An" notation!
#define XM A1 // must be an analog pin, use "An" notation!
#define YM 14 // can be a digital pin, this is A0
#define XP 17 // can be a digital pin, this is A3
#endif
void setup()
{
Tft.init(); //init TFT library
pinMode(0,OUTPUT);
// X-Y-Length-Height //
Tft.fillRectangle(0, 0, 240, 320, WHITE); //Background
Tft.fillRectangle(0, 0, 240, 12, BLUE); //blue bar
Tft.fillRectangle(212, 1, 21, 10, BLACK); // battery body
Tft.fillRectangle(210, 3, 2, 6, BLACK); // battery tip
Tft.fillRectangle(219, 2, 13, 8, GREEN); // battery level at FULL ---> (201, 2, 19, 8, GREEN);
//statusbar
Tft.drawString("Romny 12/31/12",5, 4, 1, YELLOW);
//4 squares
Tft.fillRectangle(30, 50, 80, 80, RED);//1
Tft.fillRectangle(130, 50, 80, 80, GREEN);//2
Tft.fillRectangle(30, 160, 80, 80, BLUE);//3
Tft.fillRectangle(130, 160, 80, 80, YELLOW);//4
//square Label
Tft.drawString("LED1",40, 80, 2, BLACK);
Tft.drawString("LED2",40, 190, 2, BLACK);
Tft.drawString("LED3",135, 80, 2, BLACK);
Tft.drawString("LED4",135, 190, 2, BLACK);
}
void loop()
{
}