Code used to run it:
int val = 0;The middle lead of the potentiometer was connected to analog pin #2, while digital pins 3-13 were used for digital input.
int potPin = 2; // the pin connected to the LED
void setup() {
// use a for loop to initialize each pin as an output:
for (int thisPin = 3; thisPin < 13; thisPin++) {
pinMode(thisPin, OUTPUT);
}
}
void loop() {
// turn on pins from the lowest pin to the highest:
for (int thisPin = 3; thisPin < 13; thisPin++) {
digitalWrite(thisPin, HIGH); // turn the pin on:
val = analogRead(potPin)/5; // set the delay length based on potentiometer setting
delay(val); // delay for the specified time
digitalWrite(thisPin, LOW); // turn the pin off:
}
}
No comments:
Post a Comment