Quickly look up DIY potentiometers and post links to 3 on blog.
This link has more than 3 possible DIY potentiometers
http://electronics.stackexchange.com/questions/24420/how-can-i-make-my-own-potentiometer
CODE
byte ledPin[] = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
int ledDelay;
int direction = 1;
int currentLED = 0;
int counterdirection = -1;
int secondLED = 9;
unsigned long changeTime;
int potPin = 2;
void setup() {
for (int x=0; x<10; x++){
pinMode(ledPin[x], OUTPUT);
}
changeTime = millis();
}
void loop() {
ledDelay = analogRead(potPin);
if ((millis() - changeTime) > ledDelay) {
changeLED();
changeTime = millis();
}
}
void changeLED(){
for (int x=0; x<10; x++){
digitalWrite(ledPin[x], LOW);
}
digitalWrite(ledPin[currentLED], HIGH);
digitalWrite(ledPin[secondLED], HIGH);
currentLED += direction;
secondLED += counterdirection;
if (currentLED == 4) {direction = -1;}
if (currentLED == 0) {direction = 1;}
if(secondLED == 9) {counterdirection = -1;}
if(secondLED == 5) {counterdirection = 1;}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment