four LEDs successively with switch

Wire up four LED's to pins 0-4 of the Fubarino. does nothing until a button is pressed. When the button is pressed, successively light up one LED until all four are lit with a one second delay between each light. Then wait one more second and shut off all LED's. If the button is pressed again it will repeat the behavior described above.

current error expected unqualified id bfore { token

Ive tried many if else statements , if else if all to differnt fails.

uint16_t PIN_OUT[4] = {0,1,2,3}; //
 uint16_t PIN_IN = 4; //
void setup() {
pinMode(PIN_OUT[0], OUTPUT);
pinMode(PIN_OUT[1], OUTPUT);
pinMode(PIN_OUT[2], OUTPUT);
pinMode(PIN_OUT[3], OUTPUT);
pinMode(PIN_IN, INPUT);
}
void loop() {
digitalWrite(PIN_OUT[0], !digitalRead(PIN_OUT[0])); // toggle the LED
if( digitalRead(PIN_IN) == LOW ) { // Made decision
  digitalWrite(PIN_IN, LOW);
}
else {
   delay(4000);   // false condition
}
}
{
digitalWrite(PIN_OUT[1], !digitalRead(PIN_OUT[1])); // toggle the LED
if( digitalRead(PIN_OUT[0]) == HIGH ) { // Made decision
 delay(3000); // false condition
}
}
{
digitalWrite(PIN_OUT[2], !digitalRead(PIN_OUT[2])); // toggle the LED
if( digitalRead(PIN_OUT[1]) == HIGH ) { // Made decision
 delay(2000); // false condition
}
}
{
digitalWrite(PIN_OUT[3], !digitalRead(PIN_OUT[3])); // toggle the LED
if( digitalRead(PIN_OUT[2]) == HIGH ) { // Made decision
 delay(1000); // false condition
  }
}

In you loop() try this.

Every time you see a { put up a finger and every time you see a } put down a finger, you should find a miss-match of { and }'s in your code.

Fubarino

I can't believe it, it truly exists! In the meeting, when they decided on the name, why did no-one say "wait a minute... that sounds like...."?

A very helpful troubleshooting tool is the Auto Format feature (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor). If you do an Auto Format and then compare the resulting indentation to your intended program structure, it will quickly point you to where there is a missing or extra brace. It will also be a polite thing to auto format your code before posting it on the Arduino Forum. The code you posted looks absolutely horrible and is difficult for us to read.

Another useful feature of the Arduino IDE/Arduino Web Editor is that when you place the cursor next to one bracket, it puts a box around the matching bracket. In the Arduino IDE, if the cursor is next to the closing bracket and the opening bracket is off the screen then it will show the opening bracket line in a tool tip after a short delay.

heres what I have now ,it uploads just doesnt work.

uint8_t PIN_OUT[4] = {0, 1, 2, 3}; //
uint8_t PIN_IN = 4; //
void setup() {
  pinMode(PIN_OUT[0], OUTPUT);
  pinMode(PIN_OUT[1], OUTPUT);
  pinMode(PIN_OUT[2], OUTPUT);
  pinMode(PIN_OUT[3], OUTPUT);
  pinMode(PIN_IN, INPUT); //button turn on
}
void loop() {
  digitalWrite(PIN_OUT[0], HIGH);
  delay(1000);
  digitalWrite(PIN_OUT[1], HIGH);
  delay(1000);
  digitalWrite(PIN_OUT[2], HIGH);
  delay(1000);
  digitalWrite(PIN_OUT[3], HIGH);
  delay(1000);
  if ( digitalRead(PIN_IN) == LOW ) { // Made decision

    int8_t i = 0;
    while (i < 4)
    {
      digitalWrite(PIN_OUT[i], HIGH);
      delay(1000);
      i++;
    }
  }
}

Here is my design. I hope this might help you.

4-LED Blink
If switch 1 is pressed, D1 will blink once.
If switch 2 is pressed, D2 will blink twice.
If switch 3 is pressed, D3 will blink 3x.
If switch 4 is pressed, D4 will blnk 4x.

blink_4LED_4SWITCH.ino (1.2 KB)