Hi guys, thanks so much for your help so far, but I have one more small issue to solve. I have got the 7 leds to come on individually one at a time then scroll backwards through the sequence. However I am trying to make all 7 leds come on at the same time for a couple of seconds then go out. I have written this code the long way coz if I use the same loop and a timer delay the leds come on sequentially. However, I cant seem to get past this error.
int switchpin = 11; // pin 11 connected to switch
int timer = 250; // The higher the number, the slower the timing.
int timer2 = 250;
int timer3 = 1000;
int thisPin;
int allpin2 = 2;
int allpin3 = 3;
int allpin4 = 4;
int allpin5 = 5;
int allpin6 = 6;
int allpin7 = 7;
int allpin8 = 8;
void setup()
{
// set up digital pin read for switch
// for loop need this ---> { }
for (int thisPin = 2; thisPin < 9; thisPin++)
{
// this will set pin 2 to pin 8 as output
pinMode (thisPin, OUTPUT);
}
// use a for loop to initialize each pin as an output:
pinMode (switchpin, INPUT);
}
pinMode (allpin2, OUTPUT);
PinMode (allpin3,OUTPUT);
PinMode (allpin4,OUTPUT);
PinMode (allpin5,OUTPUT);
PinMode (allpin6,OUTPUT);
PinMode (allpin7,OUTPUT);
PinMode (allpin8,OUTPUT);
}
void loop()
{
// I prefer you hook up like +5 V --- Resistor -- pin 11 --- push button --- GND
// when the switch is press ... it will produce a LOW - 0 - 0 V signal
if (digitalRead (switchpin) == LOW)
{
// you forgot the { }
delay(100); // debounce time
for (int thisPin = 2; thisPin < 9; thisPin++)
{
// loop from the lowest pin to the highest:
// turn the pin on
digitalWrite(thisPin, HIGH);
delay(timer);
// turn the pin off:
digitalWrite(thisPin, LOW);
}
// end of loop one
// loop from the highest pin to the lowest:
{
// turn the pin on:
digitalWrite(allpin2, HIGH);
digitalWrite(allpin3, HIGH);
digitalWrite(allpin4, HIGH);
digitalWrite(allpin5, HIGH);
digitalWrite(allpin6, HIGH);
digitalWrite(allpin7, HIGH);
digitalWrite(allpin8, HIGH);
delay(timer);
digitalWrite(allpin2, LOW);
digitalWrite(allpin3, LOW);
digitalWrite(allpin4, LOW);
digitalWrite(allpin5, LOW);
digitalWrite(allpin6, LOW);
digitalWrite(allpin7, LOW);
digitalWrite(allpin8, LOW);
}
// end of loop 2
}
// closing the if () stament
}
the errors are the following.
C:\Users\Skindog home\7 led switch 2\7 led switch 3\7 led switch 3.ino:38:9: error: expected constructor, destructor, or type conversion before '(' token
pinMode (allpin2, OUTPUT);
^
C:\Users\Skindog home\7 led switch 2\7 led switch 3\7 led switch 3.ino:39:9: error: expected constructor, destructor, or type conversion before '(' token
PinMode (allpin3,OUTPUT);
^
C:\Users\Skindog home\7 led switch 2\7 led switch 3\7 led switch 3.ino:40:9: error: expected constructor, destructor, or type conversion before '(' token
PinMode (allpin4,OUTPUT);
^
C:\Users\Skindog home\7 led switch 2\7 led switch 3\7 led switch 3.ino:41:9: error: expected constructor, destructor, or type conversion before '(' token
PinMode (allpin5,OUTPUT);
^
C:\Users\Skindog home\7 led switch 2\7 led switch 3\7 led switch 3.ino:42:9: error: expected constructor, destructor, or type conversion before '(' token
PinMode (allpin6,OUTPUT);
^
C:\Users\Skindog home\7 led switch 2\7 led switch 3\7 led switch 3.ino:43:9: error: expected constructor, destructor, or type conversion before '(' token
PinMode (allpin7,OUTPUT);
^
C:\Users\Skindog home\7 led switch 2\7 led switch 3\7 led switch 3.ino:44:9: error: expected constructor, destructor, or type conversion before '(' token
PinMode (allpin8,OUTPUT);
^
C:\Users\Skindog home\7 led switch 2\7 led switch 3\7 led switch 3.ino:45:1: error: expected declaration before '}' token
}
^
exit status 1
Compilation error: expected constructor, destructor, or type conversion before '(' token
Once again many thanks for taking the time to help