Hi i'm new to the arduino and have play with some of the easier projects and wanted to try something bigger so i triedto make a toggle switch panel for a game. now since i have add more switches and now i get this
test2:42: error: 'currentState' does not name a type
test2:43: error: expected unqualified-id before 'if'
test2:46: error: expected unqualified-id before 'else'
test2:50: error: 'lastState' does not name a type
test2:51: error: expected declaration before '}' token
'currentState' does not name a type
and here is apart of the sketch
// the pin that the pushbutton is attached to
const int buttonPin_1 = 13;
const int buttonPin_2 = 12;
const int buttonPin_3 = 11;
const int buttonPin_4 = 10;
const int buttonPin_5 = 9;
const int buttonPin_6 = 8;
boolean currentState = LOW;//stroage for current button state
boolean lastState = LOW;//storage for last button state
void setup() {
** // initialize the button pin as a input:**
** pinMode(buttonPin_1, INPUT);**
** pinMode(buttonPin_2, INPUT);**
** pinMode(buttonPin_3, INPUT);**
** pinMode(buttonPin_4, INPUT);**
** pinMode(buttonPin_5, INPUT);**
** pinMode(buttonPin_6, INPUT);**
** // initialize serial communication:**
** Serial.begin(9600);**
}
void loop(){
** currentState = digitalRead(buttonPin_1);**
** if (currentState == HIGH && lastState == LOW){//if button has just been pressed**
** Serial.println("Headlights");**
** delay(2);//crude form of button debouncing**
** } else if(currentState == LOW && lastState == HIGH){**
** Serial.println("Headlights");**
** delay(1);//crude form of button debouncing**
** }**
** lastState = currentState;**
}
** currentState = digitalRead(buttonPin_2); <---this is where i get 'currentState' dose not name a type **
** if (currentState == HIGH && lastState == LOW){**
** Serial.println("Windshield Wipers");**
** delay(2);**
** } else if(currentState == LOW && lastState == HIGH){**
** Serial.println("Windshield Wipers");**
** delay(1);**
** }**
** lastState = currentState;**
}
and i have add the sketch to if you want to see the full code. if any one can help that would be great and sorry if i have put this in the wrong place
test2.ino (2.56 KB)