void setup() { pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, INPUT); // put your setup code here, to run once: } int i; bool a; void loop() { digitalWrite(5, HIGH); if(digitalRead(6)==HIGH&&a==false){ for(i=0;i<10;i++){ digitalWrite(2, HIGH); delayMicroseconds(525); digitalWrite(2, LOW); delayMicroseconds(19475); } a=true; digitalWrite(4, LOW); digitalWrite(3, HIGH); } else if(digitalRead(6)==HIGH&&a==true){ for(i=0;i<10;i++){ digitalWrite(2, HIGH); delayMicroseconds(900); digitalWrite(2, LOW); delayMicroseconds(19100); } a=false; digitalWrite(4, LOW); digitalWrite(3, HIGH); } else{ digitalWrite(4, LOW); digitalWrite(3, LOW); } // put your main code here, to run repeatedly: }