int trangthaitruoc = HIGH;
int count = 0;
void setup() {
// put your setup code here, to run once:
pinMode(2, INPUT);
pinMode(3, OUTPUT);
pinMode(4, INPUT);
pinMode(5, OUTPUT);
pinMode(6, INPUT);
pinMode(7, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
// this speeds up the simulation
int i = digitalRead(4);
int x = digitalRead(2);
int z = digitalRead(6);
if(x==LOW && trangthaitruoc == HIGH){
count++;
delay(20);
}
trangthaitruoc =x;
if(count%2!=0){
digitalWrite(3, HIGH);
}
else{
digitalWrite(3, LOW);
}
if(i==1){
digitalWrite(5,HIGH);
delay(20);
}
else{
digitalWrite(5, LOW);
delay(20);
}
if(z==1){
digitalWrite(7,HIGH);
}
else{
digitalWrite(7, LOW);
}
}