I'm trying to do a code with servos but apparently the value "HIGH" is not working on "digitalRead" inside of 'if'. My code is below:
#include <Servo.h>
Servo srv;
void setup() {
srv.attach(9);
pinMode(7,INPUT);
pinMode(6,INPUT);
}
void loop() {
if(digitalRead(7) = HIGH){
srv.write(180);
}
if(digitalRead(6) = HIGH){
srv.write(0);
}
}
then here is the error message:
In file included from C:\Users\webch\AppData\Local\Temp\arduino\sketches\41353DAB637EDEC58BF9C67F92D422FB\sketch\sketch_sep23a.ino.cpp:1:0:
C:\Users\webch\AppData\Local\Temp.arduinoIDE-unsaved2023823-23020-8e4chy.7bznh\sketch_sep23a\sketch_sep23a.ino: In function 'void loop()':
C:\Users\webch\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Arduino.h:40:14: error: lvalue required as left operand of assignment
#define HIGH 0x1
^
C:\Users\webch\AppData\Local\Temp.arduinoIDE-unsaved2023823-23020-8e4chy.7bznh\sketch_sep23a\sketch_sep23a.ino:12:21: note: in expansion of macro 'HIGH'
if(digitalRead(7) = HIGH){
^~~~
C:\Users\webch\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Arduino.h:40:14: error: lvalue required as left operand of assignment
#define HIGH 0x1
^
C:\Users\webch\AppData\Local\Temp.arduinoIDE-unsaved2023823-23020-8e4chy.7bznh\sketch_sep23a\sketch_sep23a.ino:15:21: note: in expansion of macro 'HIGH'
if(digitalRead(6) = HIGH){
^~~~
exit status 1
Compilation error: exit status 1