boolean x = 0;//x為旗標蜂鳴器
boolean y = 0;//y為旗標led 13 pin
void setup()
{
pinMode(13, OUTPUT);
digitalWrite(13,LOW);
Serial.begin(9600);
}
void loop()
{
if (x == 0)//因為程式是由上往下exe, 狀況1:exe beep
{
for (int i = 0; i < 3; i++)
{
tone(7, 300);
delay(100);
noTone(7);
delay(1000);
}
x = 1;
}
if (y == 0)//狀況2:exe led
{
for (int i = 0; i < 3; i++)
{
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
y=1;
}}
沒有留言:
張貼留言