Arduino: 1.8.12 (Windows Store 1.8.33.0) (Windows 10), Board: "Arduino Uno"
2.2:11:5: error: redefinition of 'int buttonPin'
int buttonPin = 2;
^~~~~~~~~
C:\Users\xemnaxss\Documents\Arduino\edu\2.2\2.2.ino:10:5: note: 'int buttonPin' previously defined here
int buttonPin = 1;
^~~~~~~~~
2.2:12:5: error: redefinition of 'int buttonPin'
int buttonPin = 3;
^~~~~~~~~
C:\Users\xemnaxss\Documents\Arduino\edu\2.2\2.2.ino:10:5: note: 'int buttonPin' previously defined here
int buttonPin = 1;
^~~~~~~~~
2.2:13:5: error: redefinition of 'int buttonPin'
int buttonPin = 4;
^~~~~~~~~
C:\Users\xemnaxss\Documents\Arduino\edu\2.2\2.2.ino:10:5: note: 'int buttonPin' previously defined here
int buttonPin = 1;
^~~~~~~~~
exit status 1
redefinition of 'int buttonPin'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
You can only specify the type on the initial declaration.
This works:
int buttonPin = 1; //original declaration sets variable to 1
buttonPin = 2; // now setting variable to 2
But this gives the error you see:
int buttonPin = 1;
int buttonPin = 2; // this line causes error
See the difference?
Suggest reviewing some basic programming tutorials to get used to the syntax and rules.
thanks