Advertisement
RuiViana

Liga Bomba com tempo ajustavel

Dec 14th, 2015
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2.  
  3. LiquidCrystal lcd(12, 6, 5, 4, 3, 2);
  4.  
  5. int bomba = 10;
  6. int valvula_escape = 11;
  7. int bot_menu = 9;
  8. int bot_mais = 7;
  9. int bot_menos = 8;
  10. int valvula_solda = A1;
  11. int interruptor = A0;
  12. int contador = 0;
  13. unsigned long cont_tempo_vac = 0;
  14. unsigned long tempo;
  15. unsigned long TimeX;
  16. //------------------------------------------------
  17. void setup()
  18. {
  19. pinMode(bomba,OUTPUT);
  20. pinMode(valvula_escape,OUTPUT);
  21. pinMode(bot_menu,INPUT_PULLUP);
  22. pinMode(bot_mais,INPUT_PULLUP);
  23. pinMode(bot_menos,INPUT_PULLUP);
  24. pinMode(interruptor,INPUT_PULLUP);
  25. pinMode(valvula_solda,OUTPUT);
  26. lcd.begin(16,2);
  27. Serial.begin(9600);
  28. digitalWrite(bomba,HIGH);
  29. }
  30. //--------------------------------------------------
  31. void loop()
  32. {
  33. if(digitalRead(bot_menu) == LOW && contador == 0)
  34. {
  35. delay(500);
  36. lcd.clear();
  37. lcd.setCursor(0,0);
  38. lcd.print("TEMPO VACUO");
  39. contador = 1;
  40. }
  41. if(digitalRead(bot_mais) == LOW && contador == 1 && cont_tempo_vac <= 8)
  42. {
  43. delay(300);
  44. cont_tempo_vac = cont_tempo_vac +1;
  45. lcd.setCursor(0,1);
  46. lcd.print(cont_tempo_vac);
  47. lcd.setCursor(8,1);
  48. lcd.print("SEGUNDOS");
  49. }
  50. if(digitalRead(bot_menos) == LOW && contador == 1 && cont_tempo_vac >= 1)
  51. {
  52. delay(300);
  53. cont_tempo_vac = cont_tempo_vac -1;
  54. lcd.setCursor(0,1);
  55. lcd.print(cont_tempo_vac);
  56. lcd.setCursor(8,1);
  57. lcd.print("SEGUNDOS");
  58. }
  59. if(digitalRead(bot_menu) == LOW && contador == 1)
  60. {
  61. delay(500);
  62. lcd.clear();
  63. lcd.setCursor(0,0);
  64. lcd.print("TEMPO SELAGEM");
  65. contador = 2;
  66. }
  67. if(digitalRead(bot_menu) == LOW && contador == 2)
  68. {
  69. delay(500);
  70. lcd.clear();
  71. contador = 0;
  72. }
  73. if((digitalRead(interruptor) == LOW) && (contador == 0))
  74. {
  75. TimeX = millis();
  76. while (cont_tempo_vac>0)
  77. {
  78. tempo = millis() - TimeX ;
  79. if (tempo >= 1000)
  80. {
  81. TimeX = millis();
  82. digitalWrite(bomba,LOW);
  83. cont_tempo_vac--;
  84. lcd.print(cont_tempo_vac);
  85. }
  86. }
  87. digitalWrite(bomba,HIGH);
  88. }
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement