boolean btn_state;
boolean led_state = HIGH;
void setup()
{
pinMode(13, OUTPUT);
digitalWrite(13, led_state);
pinMode(2, INPUT);
}
void loop()
{
btn_state=digitalRead(2);
if(btn_state==LOW)
{
led_state=!led_state;
digitalWrite(13,led_state);
delay(20);
while(1)
{
btn_state=digitalRead(2);
if(btn_state==HIGH)
{
break;
}
}
delay(20);
}
}
沒有留言:
張貼留言