int led =3;
int sw=2;
int value;
void setup()
{
pinMode(led,OUTPUT);
pinMode(sw,INPUT);
}
void loop()
{
value=digitalRead(sw);
if(value==HIGH)
{
digitalWrite(led,HIGH); delay(200);
digitalWrite(led,LOW); delay(200);
}
else
{
digitalWrite(led,HIGH); delay(1000);
digitalWrite(led,LOW); delay(1000);
}
}
沒有留言:
張貼留言