Tuesday, February 19, 2008

ardiuno.prototype_001d/e = blinking LEDs with switch / sensor

This first video shows LED with an on/off switch




//Blinking LED 20080217_LivingArchitecture with Button

int ledPin = 13;
int inPin = 7;

int val = 0; 


void setup(){
pinMode(ledPin, OUTPUT);
pinMode(inPin, INPUT);
 
}

void loop(){
   val = digitalRead(inPin);
   
   if (val == HIGH) {
     digitalWrite (ledPin, LOW);
   }
   else{
     digitalWrite (ledPin, HIGH);
     delay (200);
     digitalWrite(ledPin, LOW);
     delay (1000);
   }
}

This video shows the LED's on/off rate responding to the value from photo-resistor
//20080219_Light Sensitive LED

int val = 0;

void setup(){
  pinMode(13, OUTPUT);
}

void loop(){
val = analogRead(0);

digitalWrite(13,HIGH);
delay (val);

digitalWrite(13,LOW);
delay (val);

}

Labels: , , , ,


Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?