Advertisement
Guest User

Untitled

a guest
Aug 30th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. #include <InputDebounce.h>
  2. #include <Bounce2.h>
  3. #include <Servo.h>
  4.  
  5. int buttonA = 51;
  6. int buttonB = 52;
  7. int buttonC = 53;
  8. int buttonD = 30;
  9. int buttonE = 41;
  10. int rele2 = 27;
  11. int rele3 = 28;
  12. int rele4 = 29;
  13. int rele1 = 26;
  14. int tempo = 10;
  15. int lettura = analogRead(A0);
  16. Servo myservo;
  17.  
  18. void setup()
  19. {
  20. myservo.attach(31);
  21. Serial.begin(9600);
  22. pinMode(buttonA, INPUT);
  23. pinMode(buttonB, INPUT);
  24. pinMode(buttonC, INPUT);
  25. pinMode(buttonD, INPUT);
  26. pinMode(buttonE, INPUT);
  27. pinMode(rele2, OUTPUT);
  28. pinMode(rele3, OUTPUT);
  29. pinMode(rele4, OUTPUT);
  30. pinMode(rele1, OUTPUT);
  31. }
  32.  
  33. void loop()
  34. {
  35. Serial.println();
  36. int alpha=LOW;
  37. int beta=LOW;
  38. int gamma=LOW;
  39. int soglia=250;
  40. int memoria;
  41. int bevanda;
  42. digitalWrite(rele1, HIGH);
  43. digitalWrite(rele4, HIGH);
  44. digitalWrite(rele3, HIGH);
  45. digitalWrite(rele2, HIGH);
  46.  
  47.  
  48. if(digitalRead(buttonA)==HIGH)
  49. {
  50. alpha=HIGH;
  51. }
  52.  
  53. if(digitalRead(buttonB)==HIGH)
  54. {
  55. beta=HIGH;
  56. }
  57.  
  58. if(digitalRead(buttonC)==HIGH)
  59. {
  60. gamma=HIGH;
  61. }
  62.  
  63.  
  64. while(memoria==HIGH)
  65. {
  66.  
  67. if(alpha==HIGH)
  68. {
  69. digitalWrite(rele1, HIGH);
  70. digitalWrite(rele2, HIGH);
  71. }
  72.  
  73. if(beta==HIGH)
  74. {
  75. digitalWrite(rele1, HIGH);
  76. digitalWrite(rele3, HIGH);
  77. }
  78.  
  79. if(gamma==HIGH)
  80. {
  81. digitalWrite(rele1, HIGH);
  82. digitalWrite(rele4, HIGH);
  83. }
  84.  
  85. if(lettura < soglia)
  86. {
  87. memoria=HIGH;
  88. }
  89.  
  90. else {memoria=LOW;}
  91.  
  92. if(memoria==LOW){break;}
  93.  
  94. }
  95.  
  96.  
  97.  
  98.  
  99.  
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement