sketch_jan17a.ino 856 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. void setup() {
  2. pinMode(2, OUTPUT);
  3. pinMode(3, OUTPUT);
  4. pinMode(4, OUTPUT);
  5. pinMode(5, OUTPUT);
  6. pinMode(6, INPUT);
  7. // put your setup code here, to run once:
  8. }
  9. int i;
  10. bool a;
  11. void loop() {
  12. digitalWrite(5, HIGH);
  13. if(digitalRead(6)==HIGH&&a==false){
  14. for(i=0;i<10;i++){
  15. digitalWrite(2, HIGH);
  16. delayMicroseconds(525);
  17. digitalWrite(2, LOW);
  18. delayMicroseconds(19475);
  19. }
  20. a=true;
  21. digitalWrite(4, LOW);
  22. digitalWrite(3, HIGH);
  23. }
  24. else if(digitalRead(6)==HIGH&&a==true){
  25. for(i=0;i<10;i++){
  26. digitalWrite(2, HIGH);
  27. delayMicroseconds(900);
  28. digitalWrite(2, LOW);
  29. delayMicroseconds(19100);
  30. }
  31. a=false;
  32. digitalWrite(4, LOW);
  33. digitalWrite(3, HIGH);
  34. }
  35. else{
  36. digitalWrite(4, LOW);
  37. digitalWrite(3, LOW);
  38. }
  39. // put your main code here, to run repeatedly:
  40. }