#include <IRremote.h>
#include <LiquidCrystal.h>
const int RECV_PIN = 8;
IRrecv irrecv(RECV_PIN);
decode_results results;
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
int x=0;
int y=0;
int z=0;
void setup() {
pinMode(12, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
irrecv.enableIRIn();
Serial.begin(9600);
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print("Home Automation");
}
void loop() {
if (irrecv.decode(&results))
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Bulb Fan Speed");
if(results.value == 0xFD08F7)
{
x++;
if(x%2==1)
{
digitalWrite(12, HIGH);
lcd.setCursor(0,2);
lcd.print("ON");
}
else
{
digitalWrite(12, LOW);
lcd.setCursor(0,2);
lcd.print("OFF");
}
}
if(results.value == 0xFD8877)
{
y++;
if(y%2==1)
{
digitalWrite(9, HIGH);
lcd.setCursor(5,2);
lcd.print("ON");
lcd.setCursor(9,2);
lcd.print(z);
}
else
{
digitalWrite(9, LOW);
lcd.setCursor(5,2);
lcd.print("OFF");
lcd.setCursor(9,2);
lcd.print(z);
}
}
if(results.value == 0xFD807F && z>=0 && z<6)
{
z++;
if(z==1)
{
analogWrite(10, 51);
lcd.setCursor(9,2);
lcd.print(z);
}
if(z==2)
{
analogWrite(10, 102);
lcd.setCursor(9,2);
lcd.print(z);
}
if(z==3)
{
analogWrite(10, 153);
lcd.setCursor(9,2);
lcd.print(z);
}
if(z==4)
{
analogWrite(10, 204);
lcd.setCursor(9,2);
lcd.print(z);
}
if(z==5)
{
analogWrite(10, 255);
lcd.setCursor(9,2);
lcd.print(z);
}
}
if(results.value == 0xFD906F && z>0 && z<=6)
{
z--;
if(z==1)
{
analogWrite(10, 51);
lcd.setCursor(9,2);
lcd.print(z);
}
if(z==2)
{
analogWrite(10, 102);
lcd.setCursor(9,2);
lcd.print(z);
}
if(z==3)
{
analogWrite(10, 153);
lcd.setCursor(9,2);
lcd.print(z);
}
if(z==4)
{
analogWrite(10, 204);
lcd.setCursor(9,2);
lcd.print(z);
}
if(z==5)
{
analogWrite(10, 255);
lcd.setCursor(9,2);
lcd.print(z);
}
if(z==0)
{
analogWrite(10, 0);
lcd.setCursor(9,2);
lcd.print(z);
}
}
Serial.println(results.value, HEX);
Serial.print(x);
Serial.print(y);
Serial.print(z);
irrecv.resume();
}
}
Comments