So I'm trying to make it so that when it gets dark these LED's turn on and blink in sequence for a bit then turn off. I've got the blinking down but cannot make it so that it only does it when it gets dark (and have no clue how to make it so that it turns off by itself...but I guess that's not really necessary, but would just be nice) I'm using an UNO and here's my code thus far:
int timer = 100;
int sensorPin = A0;
unsigned int sensorValue = 0;
int pinArray[] = {2,3,4};
void setup() {
// use a for loop to initialize each pin as an output:
Serial.begin(9600);
for (int thisPin = 2; thisPin < 8; thisPin++) {
pinMode(thisPin, OUTPUT);
}
}
void loop() {
sensorValue = analogRead(sensorPin);
if (sensorValue>190) digitalWrite(pinArray[2], LOW);
else for (int thisPin = 2; thisPin < 8; thisPin++)
{ digitalWrite(thisPin, HIGH);
delay(timer);
digitalWrite(thisPin, LOW); }
for (int thisPin = 7; thisPin >= 2; thisPin--)
{ digitalWrite(thisPin, HIGH);
delay(timer);
digitalWrite(thisPin, LOW); }
}