Created
May 14, 2017 12:42
-
-
Save prasant1010/5215f6aba6b3591c2358b923461c28ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
created by prasant | |
www.electronify.org | |
you can do what ever you want with this piece of code | |
*/ | |
#include <LiquidCrystal.h>` | |
LiquidCrystal lcd(10, 9, 8, 7, 6, 5); | |
int incomingByte = 0; // for incoming serial data | |
const int relayPin1 = 13; // the number of the relay pin | |
const int relayPin2 = 12 ; | |
const int relayPin3 = 11; | |
void setup() | |
{ | |
pinMode(relayPin1, OUTPUT); | |
pinMode(relayPin2,OUTPUT); | |
pinMode(relayPin3,OUTPUT); | |
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps | |
lcd.begin (20, 4); | |
lcd.clear (); | |
lcd.setCursor (0, 0); | |
lcd.print ("WWW.ELECTRONIFY.ORG"); | |
} | |
void loop() { | |
// send data only when you receive data: | |
if (Serial.available() > 0) { | |
// read the incoming byte: | |
incomingByte = Serial.read(); | |
if(incomingByte==1) | |
{ | |
lcd.setCursor (0, 1); | |
lcd.print("LAMP1 IS ON "); | |
digitalWrite(relayPin1, HIGH); | |
} | |
else if(incomingByte==2) | |
{ | |
lcd.setCursor (0, 1); | |
lcd.print("FAN IS ON "); | |
digitalWrite(relayPin2, HIGH); | |
} | |
else if (incomingByte==3) | |
{ | |
lcd.setCursor (0, 1); | |
lcd.print("LAMP2 IS ON "); | |
digitalWrite(relayPin3, HIGH); | |
} | |
else | |
{ | |
lcd.setCursor (0, 1); | |
lcd.print("press button "); | |
digitalWrite(relayPin1, LOW); | |
digitalWrite(relayPin2, LOW); | |
digitalWrite(relayPin3, LOW); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment