Doing my best to start small and it seems I'm even failing at that!
All I wanna do is use a pushbutton to count to 5 and display the results to 3 LED's in a binary form.
int buttonState = 0;
int count = 0;
void setup() { Serial.begin(9600); pinMode(2,INPUT); pinMode(3,OUTPUT); pinMode(4,OUTPUT); pinMode(5,OUTPUT); }
void loop() { digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW);
buttonState = digitalRead(2);
if(buttonState == LOW) {
} else { count++; delay(500); Serial.print(count);
if((count == 1)) { digitalWrite(3, HIGH); } }
if((count == 2)) { digitalWrite(4, HIGH); } }
if((count == 3)) { digitalWrite(3,4, HIGH); } }
if((count == 4)) { digitalWrite(5, HIGH); } }
if((count == 5)) { digitalWrite(5,3, HIGH); } delay(500); } }
Here's the error message:
Arduino: 1.8.5 (Windows 8.1), Board: "Arduino/Genuino Uno"
sketch_nov25a:18: error: expected unqualified-id before 'if'
if((count == 3)) { digitalWrite(3,4, HIGH); } }
^
sketch_nov25a:18: error: expected declaration before '}' token
if((count == 3)) { digitalWrite(3,4, HIGH); } }
^
exit status 1
expected unqualified-id before 'if'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Apparently it's not as simple as I thought. But ya gotta start somewhere.