Sunday, October 18, 2009

LED Array

int timer = 100; 
int ledPins[] = {2,3,4,5,6 }; 
int pinCount = 5; 
int analogPin = 0;
int analogValue = 0;

void setup() {
Serial.begin(9600);
for (int whatPin = 0;  whatPin<5;>
pinMode(ledPins[whatPin], OUTPUT);
}
}
void loop() { 
int analogValue = analogRead(analogPin);

Serial.println(analogValue);
if(analogValue >= 50) {
for (int whatPin = 0;  whatPin<5;>

  digitalWrite(ledPins[whatPin], HIGH);
delay(timer);

digitalWrite(ledPins[whatPin], LOW);
}}
  if(analogValue <= 49) {
for (int whatPin = 5;  whatPin>0; whatPin--) {

digitalWrite(ledPins[whatPin], HIGH);
delay(timer);

digitalWrite(ledPins[whatPin], LOW);
}
}
}

video

No comments:

Post a Comment