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