int green,9;
int gstate=HIGH;
int red,8;
int rstate,HIGH;
int pump,13;
int pstate=HIGH;
int button,1;
int buttoncurrent;
int buttonprev=LOW;
void setup() {
// put your setup code here, to run once:
pinMode(green,OUTPUT);
pinMode(red,OUTPUT);
pinMode(pump,OUTPUT);
pinMode(button,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
Buttoncurrent=digitalRead(button);
if (buttoncurrent==HIGH&&buttonprev==LOW)
{
if(rstate==HIGH)
{
rstate=LOW;
gstate=HIGH;
}
else
{
rstate=HIGH;
gstate=LOW;
}
}
digitalWrite(red,rstate);
digitalWrite(green,gstate);
buttonprev=bottoncurrent;
}
I have had problems with the error message before and decided to bite the bullet and fix it. I reinstalled the Arduino IDE and still had this problem. The end result should be a push button toggle , that starts on Red and when the button is pressed once the red will change Green. I am using a push button, Rgb LED, 330 resistor for the LED and a 10k for the push button. my error code is the following: Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"
sketch_jan28a:1:11: error: expected unqualified-id before numeric constant
int green,9;
^
sketch_jan28a:3:9: error: expected unqualified-id before numeric constant
int red,8;
^
In file included from sketch\sketch_jan28a.ino.cpp:1:0:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:40:14: error: expected unqualified-id before numeric constant
#define HIGH 0x1
^
C:\Users\alexw\AppData\Local\Temp\arduino_modified_sketch_25108\sketch_jan28a.ino:4:12: note: in expansion of macro 'HIGH'
int rstate,HIGH;
^~~~
sketch_jan28a:5:10: error: expected unqualified-id before numeric constant
int pump,13;
^~
sketch_jan28a:7:16: error: expected unqualified-id before numeric constant
int pushbutton,1;
^
C:\Users\alexw\AppData\Local\Temp\arduino_modified_sketch_25108\sketch_jan28a.ino: In function 'void setup()':
sketch_jan28a:15:9: error: 'button' was not declared in this scope
pinMode(button,INPUT);
^~~~~~
C:\Users\alexw\AppData\Local\Temp\arduino_modified_sketch_25108\sketch_jan28a.ino:15:9: note: suggested alternative: 'ultoa'
pinMode(button,INPUT);
^~~~~~
ultoa
C:\Users\alexw\AppData\Local\Temp\arduino_modified_sketch_25108\sketch_jan28a.ino: In function 'void loop()':
sketch_jan28a:20:1: error: 'Buttoncurrent' was not declared in this scope
Buttoncurrent=digitalRead(button);
^~~~~~~~~~~~~
C:\Users\alexw\AppData\Local\Temp\arduino_modified_sketch_25108\sketch_jan28a.ino:20:1: note: suggested alternative: 'buttoncurrent'
Buttoncurrent=digitalRead(button);
^~~~~~~~~~~~~
buttoncurrent
sketch_jan28a:20:27: error: 'button' was not declared in this scope
Buttoncurrent=digitalRead(button);
^~~~~~
C:\Users\alexw\AppData\Local\Temp\arduino_modified_sketch_25108\sketch_jan28a.ino:20:27: note: suggested alternative: 'ultoa'
Buttoncurrent=digitalRead(button);
^~~~~~
ultoa
sketch_jan28a:38:12: error: 'bottoncurrent' was not declared in this scope
buttonprev=bottoncurrent;
^~~~~~~~~~~~~
C:\Users\alexw\AppData\Local\Temp\arduino_modified_sketch_25108\sketch_jan28a.ino:38:12: note: suggested alternative: 'buttoncurrent'
buttonprev=bottoncurrent;
^~~~~~~~~~~~~
buttoncurrent
exit status 1
expected unqualified-id before numeric constant
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.