manhoosbilli1

LCD menu with button

Jul 9th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <LiquidCrystal_I2C.h>
  3. LiquidCrystal_I2C lcd(0x27, 16, 2);
  4. #include <Bounce2.h>
  5. #define btn_up 12
  6. #define btn_up 11
  7. #define btn_select 10
  8.  
  9. void setup() {
  10. // put your setup code here, to run once:
  11. pinMode(btn_up,INPUT_PULLUP);
  12. debouncer1.attach(btn_up);
  13. debouncer1.interval(25); // interval in ms
  14. pinMode(btn_down,INPUT_PULLUP);
  15. debouncer2.attach(btn_down);
  16. debouncer2.interval(25);
  17. pinMode(btn_select,INPUT_PULLUP);
  18. debouncer2.attach(btn_select);
  19. debouncer2.interval(25);
  20.  
  21. //ask if the user wants to start incubating procedure if
  22. //not already in the process
  23.  
  24. }
  25. enum pages {
  26. DEFAULT_SENSOR,MANUAL_MTR_TURN,
  27. MOTOR_DEMO, TOGGLE_ALARM,
  28. SHOW_TIME, CALCULATE_HATCHDATE
  29. };
  30.  
  31. int currentPage = DEFAULT_SENSOR;
  32. void loop() {
  33. debouncer1.update();
  34. debouncer2.update();
  35. debouncer3.update();
  36. Up = debouncer1.read();
  37. Down = debouncer2.read();
  38. Select = debouncer2.read();
  39.  
  40.  
  41. }
  42.  
  43. void updateAlarm(){
  44. //update sens value
  45. }
  46.  
  47.  
  48. void menu() {
  49. case DEFAULT_SENSOR:
  50. //updateAlarms(); this will contain all the timers
  51. lcd.setCursor(0,2);
  52. lcd.print("T: ");
  53. //show temperature from sensor
  54. lcd.print("34.6 C*");
  55. lcd.setCursor(1,2);
  56. lcd.print("H: ");
  57. lcd.print("50 %");
  58. //show humidity from sensor
  59. break;
  60.  
  61. case CALCULATE_HATCHDATE:
  62. break;
  63.  
  64. case MANUAL_MTR_TURN:
  65. //if button pushed
  66. //turn on the flag
  67. //the function will run it once and then turn off the flag
  68. break;
  69.  
  70. case MOTOR_DEMO:
  71. //motor will go to the other switch stay there for 10 seconds
  72. //and then come back to original position.
  73. break;
  74.  
  75. case TOGGLE_BUZZER:
  76. //will read from eeprom status of alarm
  77. //if enabled it will disable the alarm
  78. //if disabled it will make the alarm buzz for 2 seconds and
  79. //then turn off giving a message as "succeful"
  80. break;
  81.  
  82.  
  83. case SHOW_TIME:
  84. //will show time for 5 seconds and go back to default page
  85. break;
  86.  
  87. }
  88.  
  89.  
  90.  
  91. void updateBuzzer(){
  92. }
  93.  
  94. void countDownForHatch(){
  95. }
Add Comment
Please, Sign In to add comment