Arduino: 1.8.9 (Windows 8.1), Board: "Arduino/Genuino Uno" HomeAutomation_using

#include <IRremote.h>

int IRpin = 11;
IRrecv irrecv(IRpin);
decode_results results;
int Relay1=4; // Initializing the pins for Relay
int Relay2=5;
int Relay3=6;
int Relay4=7;
int Relay5=12;
int Relay6=9;
int Relay7=10;
int Relay8=13;
int val1=0; // Inializing the variable for storing the last status of Relay_pins
int val2=0;
int val3=0;
int val4=0;
int val5=0;
int val7=0;
int val8=0;
int val9=0;
int val10=0;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode(Relay1,OUTPUT);
pinMode(Relay2,OUTPUT);
pinMode(Relay3,OUTPUT);
pinMode(Relay4,OUTPUT);
pinMode(Relay5,OUTPUT);
pinMode(Relay6,OUTPUT);
pinMode(Relay7,OUTPUT);
pinMode(Relay8,OUTPUT);
digitalWrite(Relay1,HIGH);
digitalWrite(Relay2,HIGH);
digitalWrite(Relay3,HIGH);
digitalWrite(Relay4,HIGH);
digitalWrite(Relay5,HIGH);
digitalWrite(Relay6,HIGH);
digitalWrite(Relay7,HIGH);
digitalWrite(Relay8,HIGH);
}
void loop()

{
if (irrecv.decode(&results))
{
Serial.println(results.value);
delay(10);

irrecv.resume();
}

if(results.value==33444015)
{
val1=digitalRead(Relay1);
if(val1==0)
{
digitalWrite(Relay1,HIGH);
val1=1;
delay(100);
}
else
{
digitalWrite(Relay1,LOW);
val1=0;
delay(100);
}
}

if(results.value==33478695)
{
val1=digitalRead(Relay2);
if(val2==0)
{
digitalWrite(Relay2,HIGH);
val2=1;
delay(100);
}
else
{
digitalWrite(Relay2,LOW);
val2=0;
delay(100);
}
}

if(results.value==33486855)
{
val1=digitalRead(Relay3);
if(val3==0)
{
digitalWrite(Relay3,HIGH);
val3=1;
delay(100);
}
else
{
digitalWrite(Relay3,LOW);
val3=0;
delay(100);
}
}

if(results.value==33435855)
{
val4=digitalRead(Relay4);
if(val4==0)
{
digitalWrite(Relay4,HIGH);
val4=1;
delay(100);
}
else
{
digitalWrite(Relay4,LOW);
val4=0;
delay(100);
}
}
if(results.value==33468495)
{
val1=digitalRead(Relay5);
if(val5==0)
{
digitalWrite(Relay5,HIGH);
val5=1;
delay(100);
}
else
{
digitalWrite(Relay5,LOW);
val5=0;
delay(100);
}
}
if(results.value==33423615)
{
val7=digitalRead(Relay6);
if(val7==0)
{
digitalWrite(Relay6,HIGH);
val7=1;
delay(100);
}
else
{
digitalWrite(Relay6,LOW);
val8=0;
delay(100);
}
}

if(results.value==33452175)
{
val9=digitalRead(Relay7);
if(val9==0)
{
digitalWrite(Relay7,HIGH);
val8=1;
delay(100);
}
else
{
digitalWrite(Relay7,LOW);
val8=0;
delay(100);
}
}
if(results.value==33484815)
{
val9=digitalRead(Relay8);
if(val9==0)
{
digitalWrite(Relay8,HIGH);
val9=1;
delay(100);
}
else
{
digitalWrite(Relay8,LOW);
val9=0;
delay(100);
}
}
if(results.value==33441975)
{
digitalWrite(Relay1,0);
digitalWrite(Relay1,0);
digitalWrite(Relay2,0);
digitalWrite(Relay3,0);
digitalWrite(Relay4,0);
digitalWrite(Relay5,0);
digitalWrite(Relay6,0);
digitalWrite(Relay7,0);
digitalWrite(Relay8,0);

}

}

if(results.value ==33454215)
{

digitalWrite(Relay1,1);
digitalWrite(Relay2,1);
digitalWrite(Relay3,1);
digitalWrite(Relay4,1);
digitalWrite(Relay5,1);
digitalWrite(Relay6,1);
digitalWrite(Relay7,1);
digitalWrite(Relay8,1);

}

}

Have you got a question ?

Did you read this before posting a programming question ?