Hi
I'm a novice in programming arduino.
I'm trying to copy a program in the book "le livre de projets arduino" sent with my arduino kit.
In page 83 the program begins by an array declaration :
int buttons[6];
int buttons[0] = 2;
this 2nd line returns an error : conflicting declaration 'int buttons [0]'
I don't understand this error.
Thanks for your help.
Gates
September 16, 2018, 9:26pm
2
You have assigned two variables with the same name
system
September 16, 2018, 9:26pm
3
I don't understand this error
I don't have the book, but the
int buttons[0] = 2;
is clearly nonsense.
buttons[0] = 2;
is valid, but only in a function.
hammy
September 16, 2018, 10:06pm
4
You can declare arrays in several ways:
int myValues[6]; int myPins[] = {2, 4, 8, 3, 6}; int mySensVals[6] = {2, 4, -8, 3, 2}; char message[6] = "hello";
To assign a value to an array position ; eg position1, in the first example,you would just type myValues[1]=6;
Thanks all.
I tried to delete 'int', but it returns another error
int buttons[6];
buttons[0] = 2;
Error : 'buttons' does not name a type
lucius77:
Thanks all.
I tried to delete 'int', but it returns another error
int buttons[6];
buttons[0] = 2;
Error : 'buttons' does not name a type
The assignment of a value to a previously declared variable must be done in a function as previously mentioned in reply #2