Error Compiling for board Arduino Uno (I cannot write any programs on any boards and cannot figure out why)

I am getting this error on all programs I write.

In file included from sketch\sanitycheck.ino.cpp:1:0:
C:\Users\jarrod\Documents\Arduino\sanitycheck\sanitycheck.ino: In function 'void loop()':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:40:14: error: lvalue required as left operand of assignment
 #define HIGH 0x1
              ^
C:\Users\jarrod\Documents\Arduino\sanitycheck\sanitycheck.ino:12:32: note: in expansion of macro 'HIGH'
   if (digitalRead(switchPin) = HIGH)
                                ^~~~
exit status 1
Error compiling for board Arduino Uno.

I have uninstalled and reinstalled the Arduino IDE and libraries with no success. Here is the code to this specific error message

int switchPin = 8;
int LEDpin = 6;

void setup() {
  pinMode(switchPin, INPUT);
  pinMode(LEDpin, OUTPUT);

}

void loop() {
  if (digitalRead(switchPin) = HIGH)
  {
    digitalWrite(LEDpin, HIGH);
  }

}

I have looked at a few forum posts where it appeared the solution was found in the program itself, I have not done anything in the Arduino IDE for a few months so if the code has a fatal flaw I am just not seeing I apologize for wasting anyone's time.

The "equal" operator is == and not = as in your code

So embarrassing, Thank you

:sweat_smile:

It happens

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.