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