video is on vimeo: https://vimeo.com/56826359
password: sensors
Here is the code that I used:
// ugly sweater v.2
byte oneYellow = 13;
byte oneRed = 12;
byte oneBlue = 11;
byte twoYellow = 10;
byte twoRed = 9;
byte twoBlue = 8;
byte thrYellow = 7;
byte thrRed = 6;
byte thrBlue = 5;
byte fourYellow = 4;
byte fourRed = 3;
byte fourBlu = 2;
int ledDelay; // delay between changes
unsigned long changeTime;
int potPin = A2; // select the input pins for the potentiometer
void setup(){
pinMode(oneYellow, OUTPUT);
pinMode(oneRed, OUTPUT);
pinMode(oneBlue, OUTPUT);
pinMode(twoYellow, OUTPUT);
pinMode(twoRed, OUTPUT);
pinMode(twoBlue, OUTPUT);
pinMode(thrYellow, OUTPUT);
pinMode(thrRed, OUTPUT);
pinMode(thrBlue, OUTPUT);
pinMode(fourYellow, OUTPUT);
pinMode(fourRed, OUTPUT);
pinMode(fourBlu, OUTPUT);
changeTime = millis();
pinMode(potPin, INPUT);
}
void loop(){
int valPin = analogRead(potPin);
unsigned long tmDelay = map(valPin, 0, 1023, 500, 0);
digitalWrite(oneYellow, HIGH);
digitalWrite(oneRed, HIGH);
digitalWrite(oneBlue, HIGH);
digitalWrite(twoBlue, LOW);
digitalWrite(thrBlue, LOW);
digitalWrite(fourBlu, LOW);
delay(tmDelay);
digitalWrite(twoYellow, HIGH);
digitalWrite(twoRed, HIGH);
digitalWrite(twoBlue, HIGH);
digitalWrite(oneYellow, LOW);
digitalWrite(oneRed, LOW);
digitalWrite(oneBlue, LOW);
delay(tmDelay);
digitalWrite(thrYellow, HIGH);
digitalWrite(thrRed, HIGH);
digitalWrite(thrBlue, HIGH);
digitalWrite(twoYellow, LOW);
digitalWrite(twoRed, LOW);
digitalWrite(twoBlue, LOW);
delay(tmDelay);
digitalWrite(fourYellow, HIGH);
digitalWrite(fourRed, HIGH);
digitalWrite(fourBlu, HIGH);
digitalWrite(thrYellow, LOW);
digitalWrite(thrRed, LOW);
digitalWrite(thrBlue, LOW);
delay(tmDelay);
digitalWrite(fourYellow, LOW);
digitalWrite(fourRed, LOW);
digitalWrite(fourBlu, LOW);
digitalWrite(oneYellow, HIGH);
digitalWrite(twoYellow, HIGH);
digitalWrite(thrYellow, HIGH);
digitalWrite(fourYellow, HIGH);
delay(tmDelay);
digitalWrite(oneYellow, LOW);
digitalWrite(twoYellow, LOW);
digitalWrite(thrYellow, LOW);
digitalWrite(fourYellow, LOW);
digitalWrite(oneRed, HIGH);
digitalWrite(twoRed, HIGH);
digitalWrite(thrRed, HIGH);
digitalWrite(fourRed, HIGH);
delay(tmDelay);
digitalWrite(oneRed, LOW);
digitalWrite(twoRed, LOW);
digitalWrite(thrRed, LOW);
digitalWrite(fourRed, LOW);
digitalWrite(oneBlue, HIGH);
digitalWrite(twoBlue, HIGH);
digitalWrite(thrBlue, HIGH);
digitalWrite(fourBlu, HIGH);
delay(tmDelay);
digitalWrite(twoBlue, LOW);
digitalWrite(thrBlue, LOW);
digitalWrite(fourBlu, LOW);
}
No comments:
Post a Comment