I have been trying for lots of time to figure this out … But nothing seems wrong in the code !!
Here is the code – pretty much simple code…
#include <IRremote.h>
decode_results results;
//------------------------PINS---------------------------\\
const int relay1 = 13;
IRrecv irrecv(8); // Infrared Reciever
//------------------------End of PINS--------------------\\
bool LightCondition = false; // false = Off -- true = On
void setup() {
// put your setup code here, to run once:
//--------------------PinModes & Pin Intialize Conditions-----------------\\
pinMode(relay1,OUTPUT);
digitalWrite(relay1,LOW);
//--------------------End of PinModes & Pin Intialize Conditions-----------------\\
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop() {
// put your main code here, to run repeatedly:
if (irrecv.decode(&results))
{
String IRresult = String(results.value,HEX);
Serial.println(Alpha, HEX);
ProcessRemoteControl(Alpha);
irrecv.resume(); // Receive the next value
}
}
void ProcessRemoteControl(String Alpha)
{
if(Alpha == "409F50AF") // Power Button
{
LightCondition = !LightCondition;
digitalWrite(relay1,LightCondition);
}
}
And the error is :
Arduino: 1.6.10 (Windows 7), Board: "Arduino/Genuino Uno"
C:\Users\Mohammed\Documents\Arduino\sketch_sep10a\sketch_sep10a.ino: In function 'void setup()':
sketch_sep10a:18: error: 'relay1' was not declared in this scope
pinMode(relay1,OUTPUT);
^
C:\Users\Mohammed\Documents\Arduino\sketch_sep10a\sketch_sep10a.ino: In function 'void loop()':
sketch_sep10a:36: error: 'Alpha' was not declared in this scope
Serial.println(Alpha, HEX);
^
C:\Users\Mohammed\Documents\Arduino\sketch_sep10a\sketch_sep10a.ino: In function 'void ProcessRemoteControl(String)':
sketch_sep10a:48: error: 'relay1' was not declared in this scope
digitalWrite(relay1,LightCondition);
^
exit status 1
'relay1' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.