loading

With this project, you can control the home appliances / relays/ leds with simple touch operation, it will be quite useful when normal switches gives sparks , in a highly flame able zones, and cause the accidents, don't feel bad, if you are already know this technology,please go through the next steps to make the automation system.

Step 1: HARDWARE YOU NEED

1. Arduino UNO

2.2.4 Inch TFT LCD Dsiplay

3.some hook up wires / connecting wires

4.led/ relay board

the above hardware can be available from any online store, you want...

connect the led's to pin 13,12 or if you are using relay board connect relay 1, relay 2 to pin 13, pin 12 respectively.

Step 2: Source Code

for library and source code please click on the below link:

http://prasadtronics.blogspot.in/2017/06/arduino-t...

or if you have the patience please copy the code and add necessary library to your arduino:

sorry i don't have the video, but i will upload the video soon......

code:


#include
#include #include MCUFRIEND_kbv tft;

#define LCD_CS A3

#define LCD_CD A2

#define LCD_WR A1

#define LCD_RD A0

#define LCD_RESET A4

#define YP A1

#define XM A2

#define YM 7

#define XP 6

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

#define TS_MINX 20

#define TS_MINY 120

#define TS_MAXX 200

#define TS_MAXY 940

#define BLACK 0x0000

#define BLUE 0x001F

#define RED 0xF800

#define GREEN 0x07E0

#define CYAN 0x07FF

#define MAGENTA 0xF81F

#define YELLOW 0xFFE0

#define WHITE 0xFFFF

uint16_t g_identifier;

void setup(void)

{ Serial.begin(9600);

pinMode(13, OUTPUT);

pinMode(12, OUTPUT);

tft.reset();

delay(10);

g_identifier = tft.readID(); // some times tft.begin(0x9341); will also used but for tft like this won't work with this command.(www.mcufriend.com)

tft.begin(g_identifier);

tft.fillScreen(WHITE);

tft.setRotation(0);

tft.setTextSize(3);

tft.setTextColor(BLACK);

tft.setCursor(20, 15);

tft.println("LED-Control");

tft.setTextSize(3);

tft.setTextColor(BLACK);

tft.setCursor(100, 210);

tft.println("BY");

tft.setTextSize(3);

tft.setTextColor(BLUE);

tft.setCursor(100, 240);

tft.println("N.B.L.V");

tft.setTextSize(3);

tft.setTextColor(BLUE);

tft.setCursor(100, 280);

tft.println("PRASAAD");

//ON-BUTTONS-TEMPLATE

tft.fillCircle(40, 90, 25, GREEN); // tft.sahpe( x, y, w, h, colour)

tft.setTextSize(2);

tft.setTextColor(BLACK);

tft.setCursor(10, 83);

tft.println(" 1");

tft.fillCircle(40, 150, 25, GREEN); // tft.sahpe( x, y, w, h, colour)

tft.setTextSize(2);

tft.setTextColor(BLACK);

tft.setCursor(10, 143);

tft.println(" 2");

//OFF-BUTTONS-TEMPLATE

tft.fillCircle(120, 90, 25, RED);

tft.setTextColor(BLACK);

tft.setCursor(90, 83); tft.println(" 1");

tft.fillCircle(120, 150, 25, RED);

tft.setTextColor(BLACK);

tft.setCursor(90, 143);

tft.println(" 2");

}

#define MINPRESSURE 10

#define MAXPRESSURE 1000

void loop() {

TSPoint p = ts.getPoint();

pinMode(XM, OUTPUT);

pinMode(YP, OUTPUT);

p.x = map(p.x, TS_MINX, TS_MAXX, 0, 240);

p.y = map(p.y, TS_MINY, TS_MAXY, 0, 320);

if (p.z > MINPRESSURE && p.z < MAXPRESSURE)

{ }

if (p.z > 0)

{ //this part will read the x,y coordinated of your tft display brought from (www.mcufriend.com)

Serial.print("\tY = ");

Serial.print(p.y);

Serial.print("\tX = ");

Serial.print(p.x);

Serial.print("\tPressure = ");

Serial.println(p.z);

}

tft.setTextSize(2);

if (p.y > 50 && p.y < 100 && p.x > 300 && p.x < 500)

{ digitalWrite(13, HIGH);

Serial.print("\tLED1 ON");

tft.setTextColor(WHITE);

tft.setCursor(160, 103);

tft.println("1 OFF");

tft.setCursor(160, 103);

tft.setTextColor(GREEN);

tft.println("1 ON");

delay(1000);

}

if (p.y > 50 && p.y < 100 && p.x > 600 && p.x < 1000)

{

digitalWrite(13, LOW);

Serial.print("\tLED1 OFF");

tft.setTextColor(WHITE);

tft.setCursor(160, 103);

tft.println("1 ON");

delay(100);

tft.setCursor(160, 103);

tft.setTextColor(RED);

tft.println("1 OFF");

delay(1000);

}

if (p.y > 100 && p.y < 150 && p.x > 300 && p.x < 500)

{ digitalWrite(12, HIGH);

Serial.print("\tLED2 ON");

tft.setCursor(160, 143);

tft.setTextColor(WHITE);

tft.println("2 OFF");

tft.setCursor(160, 143);

tft.setTextColor(GREEN);

tft.println("2 ON"); delay(1000);

}

if (p.y > 100 && p.y < 150 && p.x > 700 && p.x < 1000)

{

digitalWrite(12, LOW);

Serial.print("\tLED2 OFF");

tft.setCursor(160, 143);

tft.setTextColor(WHITE);

tft.println("2 ON");

tft.setCursor(160, 143);

tft.setTextColor(RED);

tft.println("2 OFF");

delay(1000);

}

delay(1000); // is to stabilize the x,y coordinates

}

Step 3: Final Output

The final output of the project will be as shown in the picture, you can add number of devices but, don't forget to use mega2560 boards, as it does have more i/o pins.

About This Instructable

158views

9favorites

License:

More by BhaskarP6:APM Quadcopter Setup Using KK Flight Controller Board to Fixed Wing Aeroplanes Small Humanoid Robot Making 
Add instructable to: