Have been working through the Starter Kit Book and have found many discrepancies.
In the Keyboard Instrument (Project 7) sketch provided in the book, received error:
C:\Users\river\AppData\Local\Temp.arduinoIDE-unsaved2026113-972-b3ezh8.g8z7w\sketch_feb13a\sketch_feb13a.ino:2:14: error: conflicting declaration 'int buttons [0]'
int buttons[0] = 2; // give the first element of the array the value 2
^
C:\Users\river\AppData\Local\Temp.arduinoIDE-unsaved2026113-972-b3ezh8.g8z7w\sketch_feb13a\sketch_feb13a.ino:1:5: note: previous declaration as 'int buttons [6]'
int buttons[6]; // set up array with 6 integers
^~~~~~~
exit status 1
Compilation error: conflicting declaration 'int buttons [0]'
Here is the sketch as presented in the book:
int buttons[6]; // set up array with 6 integers
int buttons[0] = 2; // give the first element of the array the value 2
int notes[] = {262, 294, 330, 349};
void setup() {
Serial.begin(9600);
}
void loop() {
int keyVal = analogRead(A0);
Serial.println(keyVal);
if (keyVal == 1023) {
tone(8, notes[0]);
}
else if(keyVal >= 990 && keyVal <= 1010) {
tone(8, notes[1]);
}
else if (keyVal >= 505 && keyVal <=515) {
tone(8, notes[2]);
}
else if(keyVal >=5 && keyVal <=10){
tone(8, notes[3]);
}
else{
noTone(8);
}
}
Attempting to use <code/> tags, please advise if it is working for me :^)
AI tells me that the line: int buttons[0] = 2; is incorrect in that int has been declared in the prior line. Then deleting the int still get error and AI tells me that the line does not belong in the global declaration and should be in void setup() instead. That correction allows the sketch to compile and run.
My vision was that this was a book to show the correct structure of code, and demonstrate the uses of the board with examples that work. What my experience so far has been is that I need to find the problems in the code given and fix them to get it to function. Is this the aim of the kit? If so, my direction in following the written pages will have a different prospective.
I understand that I am new to the code, the syntax, structure, verbiage, and a lot more. That was the purpose of purchasing the kit. To learn, become familiar with this, become at least somewhat decent at understanding it. I guess repairing is a good way to learn, but it not a very positive feeling to need to fix so much while learning.
Not trying to be negative or sour, just trying to understand. Coding has been an interest for a few years and have not yet found a solid positive way to learn it. I am getting a bit better and understanding more. It has been a frustrating journey so far. My background is not electronics, mechanics, and can reason through much if I understand what things are.
Well, thank you to anyone that reads this far. And appreciation to anyone that wants to help. Want to understand and learn, have helped many in the past to understand and learn mechanics, so I know there are those who like to help others.





