int btn=2;
int led =3;
int value;
int ledState=0;
void setup()
{
pinMode(btn,INPUT);
pinMode(led,OUTPUT);
}
void loop()
{
value=digitalRead(btn);
if(value==LOW)
{
delay(20);
while(digitalRead(btn)==LOW);
ledState=ledState^1;
digitalWrite(led,ledState);
}
}
沒有留言:
張貼留言