Hi Everybody,
As the main title says, I'm approaching the Arduino and Electronics in general for my first time.
I bought a Starter kit and I start...;), On my second project I found a trouble, I follow the book to create the Spaceship interface.
I read and then copy the code from the book to the program, but I still receive an error when I hit Verify button on the program.
I posted here the code I wrote, I check it several times, but it continues to give me this error:
steve1:15: error: expected unqualified-id before numeric constant
When I hit Verify button on the program, it put on evidence this symbol } on the 4th line of the code.
If I erase the } symbol it put on evidence the following line so: 1 int switchState = 0;
Can somebody help me?
Thank you in advance guys and girls!
Steve.
void setup(){
}
void loop(){
}
1 int switchState = 0;2 void setup(){
3 pinMode(3,OUTPUT);
4 pinMode(4,OUTPUT);
5 pinMode(5,OUTPUT);
6 pinMode(2,INPUT);
}
8 void loop(){
9 switchState = digitalRead(2);
10 // Quando il programma legge il doppio slash// non legge la linea, tutto quello che resta su questa linea non viene letto dal programma e ci permette di lasciare messaggi per spiegare il funzionamento!!!!11 if (switchState == LOW) {
12 // il bottone non è premuto13 digitalWrite(3, HIGH); // LED VERDE
14 digitalWrite(4, LOW); // LED ROSSO
15 digitalWrite(5, LOW); //LED ROSSO
16 }17 else { // il pulsante viene premuto
18 digitalWrite(3, LOW);
19 digitalWrite(4, LOW);
20 digitalWrite(5, HIGH);21 delay(250); // aspetta un quarto di secondo
22 // lampeggiano i led?
23 digitalWrite(4, HIGH);
24 digitalWrite(5, LOW);
25 delay(250); // aspetta 1/4 secondi}
} // torna all'inizio del loop