int led2=12;
int led3=11;
int led4=10;
int button1=9;
int buttonStata =0;
void setup() {
pinMode(led1 , OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(button1,INPUT);
}
void loop()
{
buttonStata=digitalRead(button1);
if(buttonStata == HIGH){
digitalWrite(led1,HIGH);
delay(500);
digitalWrite(led2,HIGH);
digitalWrite(led1,LOW);
delay(500);
digitalWrite(led2,HIGH);
delay(500);
digitalWrite(led3,HIGH);
digitalWrite(led2,LOW);
delay(500);
digitalWrite(led3,HIGH);
delay(500);
digitalWrite(led4,HIGH);
digitalWrite(led3,LOW);
delay(500);
digitalWrite(led4,HIGH);
delay(500);
digitalWrite(led4,LOW);
delay(500);
buttonStata =0;
}
else
{
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
digitalWrite(led4,LOW);
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น