Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #define greenLED A0
  2. #define redLED A1
  3.  
  4. int button1 = 5;
  5. int button2 = 4;
  6. int button3 = 3;
  7.  
  8. void setup() {
  9. // put your setup code here, to run once:
  10. pinMode(A0, OUTPUT);
  11. pinMode(A1, OUTPUT);
  12. pinMode(button1, INPUT_PULLUP);
  13. pinMode(button2, INPUT_PULLUP);
  14. pinMode(button3, INPUT_PULLUP);
  15. }
  16.  
  17. void loop() {
  18. // put your main code here, to run repeatedly:
  19. int total = 0;
  20. while(digitalRead(button1) == LOW && digitalRead(button2) == LOW && digitalRead(button3) == LOW){
  21. while(digitalRead(button1) == LOW && digitalRead(button2) == LOW && digitalRead(button3) == LOW){
  22. while(digitalRead(button1) == LOW && digitalRead(button2) == LOW && digitalRead(button3) == LOW){
  23. while(digitalRead(button1) == LOW && digitalRead(button2) == LOW && digitalRead(button3) == LOW){
  24. while(digitalRead(button1) == LOW && digitalRead(button2) == LOW && digitalRead(button3) == LOW){
  25. if(digitalRead(button1) == HIGH){
  26. total = total + 1;
  27. }
  28. }
  29. if(digitalRead(button2)==HIGH){
  30. total = total+1;
  31. }
  32. }
  33. if(digitalRead(button3)==HIGH){
  34. total = total + 1;
  35. }
  36. }
  37. if(digitalRead(button3)==HIGH){
  38. total = total+1;
  39. }
  40. }
  41. if(digitalRead(button1) == HIGH){
  42. total = total+1;
  43. }
  44. }
  45. if(total == 5){
  46. digitalWrite(A0, HIGH);
  47. delay(2000);
  48. digitalWrite(A0, LOW);
  49. }else{
  50. digitalWrite(A1, HIGH);
  51. delay(2000);
  52. digitalWrite(A1, LOW);
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement