Saturday, March 29, 2008
arduino.prototype_007c_002 = flexinol + skin + switch controlling behaviour
video close ups and code
long t;
int ledPin13 = 13;
int ledPin12 = 12;
int ledPin11 = 11;
int ledPin10 = 10;
int inPin = 7;
int val = 0;
boolean flex13 = false;
boolean flex12 = false;
boolean flex11 = false;
boolean flex10 = false;
int t13 = 6000;
int t12 = 3000;
int t11 = 6000;
int t10 = 3000;
int rndMin = 4000;
int rndMax = 8000;
int base13 = 6000;
int base12 = 3000;
int base11 = 6000;
int base10 = 3000;
int flexTime = 500;
void setup(){
pinMode(ledPin13, OUTPUT);
pinMode(ledPin12, OUTPUT);
pinMode(ledPin11, OUTPUT);
pinMode(ledPin10, OUTPUT);
}
void loop(){
val = digitalRead(inPin);
t = millis();
if (t % t13 == 0){
flex13 = true;
}
if ((t - flexTime) % t13 == 0){
flex13 = false;
if (val == LOW){
t13 = int( random(rndMin,rndMax));
}
if (val == HIGH){
t13 = base13;
}
}
if (t % t12 == 0 && t % (t12*2) != 0){
flex12 = true;
}
if ((t - flexTime) % t12 == 0 && (t - flexTime) % (t12*2) != 0){
flex12 = false;
if (val == LOW){
t12 = int( random((rndMin/2),(rndMax/2)));
}
if (val == HIGH){
t12 = base12;
}
}
if (t % t11 == 0){
flex11 = true;
}
if ((t - flexTime) % t11 == 0){
flex11 = false;
if (val == LOW){
t11 = int( random(rndMin,rndMax));
}
if (val == HIGH){
t11 = base11;
}
}
if (t % t10 == 0 && t % (t10*2) != 0){
flex10 = true;
}
if ((t - flexTime) % t10 == 0 && (t - flexTime) % (t10*2) != 0){
flex10 = false;
if (val == LOW){
t10 = int( random((rndMin/2),(rndMax/2)));
}
if (val == HIGH){
t10 = base10;
}
}
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: charles, flexinol, led, random, relay, rob, switch