Thursday, March 27, 2008
arduino.prototype_005b = LEDs in aperiodic sequence
long t;
int ledPin13 = 13;
int ledPin12 = 12;
int ledPin11 = 11;
int ledPin10 = 10;
boolean flex13 = false;
boolean flex12 = false;
boolean flex11 = false;
boolean flex10 = false;
int t13;
int t12;
int t11;
int t10;
int flexTime = 1500;
boolean turbulence = true;
void setup(){
pinMode(ledPin13, OUTPUT);
pinMode(ledPin12, OUTPUT);
pinMode(ledPin11, OUTPUT);
pinMode(ledPin10, OUTPUT);
}
void loop(){
t = millis();
if (turbulence == true){
t13 = 4000;
t12 = 2250;
t11 = 4500;
t10 = 2750;
}else{
t13 = 4000;
t12 = 2000;
t11 = 4000;
t10 = 2000;
}
// set pacing value for each pin
if (t % t13 == 0){
flex13 = true;
}
if ((t - flexTime) % t13 == 0){
flex13 = false;
}
if (t % t12 == 0 && t % (t12*2) != 0){
flex12 = true;
}
if ((t - flexTime) % t12 == 0 && (t - flexTime) % (t12*2) != 0){
flex12 = false;
}
if (t % t11 == 0){
flex11 = true;
}
if ((t - flexTime) % t11 == 0){
flex11 = false;
}
if (t % t10 == 0 && t % (t10*2) != 0){
flex10 = true;
}
if ((t - flexTime) % t10 == 0 && (t - flexTime) % (t10*2) != 0){
flex10 = false;
}
// set value for each pin
if (flex13 == true){
digitalWrite(ledPin13, HIGH);
}else{
digitalWrite(ledPin13, LOW);
}
if (flex12 == true){
digitalWrite(ledPin12, HIGH);
}else{
digitalWrite(ledPin12, LOW);
}
if (flex11 == true){
digitalWrite(ledPin11, HIGH);
}else{
digitalWrite(ledPin11, LOW);
}
if (flex10 == true){
digitalWrite(ledPin10, HIGH);
}else{
digitalWrite(ledPin10, LOW);
}
}
Labels: aperiodic, charles, led, rob