Friday, November 6, 2009
002 blink on/off [arduino]
void setup(){
pinMode(2,OUTPUT);//PIN 2 is output
pinMode(3,INPUT);//PIN 3 is input
digitalWrite(2,LOW);//just to make sure: turn PIN 2 in the begining
}
void loop(){
if(digitalRead(3)==HIGH){//if current flows thru PIN 3 do this:
digitalWrite(2,HIGH);
delay(100);
digitalWrite(2,LOW);
delay(100);
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment