Hey LED people!
I'm working on my first big Arduino project. To sum it up, I want 6 LED's to blink in order (1-6) 1 second apart, but furthermore, I want to have 6 photocells corresponding to each of the 6 LED's, so before say, LED 1 lights up, I want there to be an "if" statement (if photocell(1) < constant value) that determines whether LED 1 lights up or not before waiting one second to check if LED 2 should go on or not. Kinda tough stuff and I'm definitely an amateur.
So I have a snippet of a code from an example book:
int ledPins[] = {2,3};
int photoPins[] = {0,1};
int lightsOff = 300;
void setup()
{
int index;
for(index = 0; index <= 2; index++)
{
pinMode(ledPins[index],OUTPUT);
}
Serial.begin(9600);
}
void oneOnAtATime()
{
int index;
int delayTime = 5000; // milliseconds to pause between LEDs
lightLevel = analogRead(photoPins[index]);
for(index = 0; index <= 2; index++)
{
if (lightLevel > lightsOff) {
digitalWrite(ledPins[index], HIGH); // turn LED on
delay(delayTime); // pause to slow down
}
else {
digitalWrite(ledPins[index], LOW); // turn LED off
delay(delayTime);
}
}
}
Any thoughts on how I can stick both a for() and "if" statement in there for a series of 6 analogIn photocell values?
Thanks!
Zac