Code:-
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 6, 2, 3, 4, 5);
void setup() {
Serial.begin(9600);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
digitalWrite(13,HIGH);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(" AnDrOiD BaSeD ");
lcd.setCursor(0, 1);
lcd.print("HoMe AuToMaTiOn ");
delay(2000);
lcd.clear();
lcd.print("L1 L2 L3 L4");
}
void loop() {
char sw;
sw=check();
if(sw=='a')
{
digitalWrite(10,HIGH);
lcd.setCursor(0, 1);
lcd.print("ON ");
}
if(sw=='b')
{
digitalWrite(10,LOW);
lcd.setCursor(0, 1);
lcd.print("OFF ");
}
if(sw=='c')
{
digitalWrite(11,HIGH);
lcd.setCursor(4, 1);
lcd.print("ON ");
}
if(sw=='d')
{
digitalWrite(11,LOW);
lcd.setCursor(4, 1);
lcd.print("OFF ");
}
if(sw=='e')
{
digitalWrite(12,HIGH);
lcd.setCursor(8, 1);
lcd.print("ON ");
}
if(sw=='f')
{
digitalWrite(12,LOW);
lcd.setCursor(8, 1);
lcd.print("OFF ");
}
if(sw=='g')
{
digitalWrite(13,HIGH);
lcd.setCursor(12, 1);
lcd.print("ON ");
}
if(sw=='h')
{
digitalWrite(13,LOW);
lcd.setCursor(12, 1);
lcd.print("OFF ");
}
}
int check()
{
if(Serial.available()>0)//Checking is Serial data available
{
int input = Serial.read(); //Storing value of read data into variable assigned
return input;
}
}
great work
ReplyDeleteEnthu uru sir.
DeleteThank you brother it very nice all the best
ReplyDelete