[Error] "...was not declared in this scope" Can't Figure this Out !!!

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;

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-----------------\\

  //--------------------End of PinModes & Pin Intialize Conditions-----------------\\


void loop() {
  // put your main code here, to run repeatedly:
   if (irrecv.decode(&results))
      String IRresult = String(results.value,HEX);
     Serial.println(Alpha, HEX);
     irrecv.resume(); // Receive the next value

void ProcessRemoteControl(String Alpha)
  if(Alpha == "409F50AF") // Power Button
    LightCondition = !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



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



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.

I'm trying the Compare the sketch with an old one that I made ... I compiled the old sketch (Which has similar things ...) and it doesn't give any errors with the old sketch !!

You are referring to Alpha in a location where it doesn't exist and hasn't been declared. Maybe you meant to call IRresult "alpha"?

The other issue with relay1 being undefined is because you put ended the lines in your comments with a backslash, making them comment continue onto the next line. So the line where you declare relay1 is actually being treated as part of the comment on the previous line. Remove the \ from the end of your comments.

Sorry didn't notice the Alpha part ...

Thank you :smiley: it worked :smiley:

Where is Alpha declared in your program ?