Advertisement
Guest User

ARDUINO CODE

a guest
Dec 7th, 2021
31
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ARDUINO CODE
  2.  
  3. // libraries toevoegen //
  4. #include <Wire.h>
  5. #include <Keypad.h>
  6. #include <LiquidCrystal.h>
  7. // de lcd en de buzzer instellen //
  8. LiquidCrystal lcd(A0,A1,A2,A3,A4,A5);
  9.  
  10.  
  11. // de keypad instellen //
  12. const byte ROWS=4;
  13. const byte COLS=4;
  14.  
  15. char hexaKeys[ROWS][COLS]={
  16. {'1','2','3','A'},
  17. {'4','5','6','B'},
  18. {'7','8','9','C'},
  19. {'*','0','#','D'}
  20. };
  21.  
  22. byte rowPins[ROWS]={9,8,7,6};
  23. byte colPins[COLS]={5,4,3,2};
  24.  
  25. Keypad customKeypad= Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
  26. char customKey = customKeypad.getKey();
  27.  
  28. // variabelen instellen //
  29. int timerMode=0;
  30. int countdown_time=10;
  31. int reset=0;
  32. int klaar=0;
  33. const byte buzzer=12;
  34. const byte startButton=13;
  35. const byte resetButton=12;
  36. unsigned long eventTime=1000;
  37. unsigned long previousTime=0;
  38.  
  39. // leuk symbolen instellen //
  40.  
  41.  
  42. // setup //
  43. void setup() {
  44. lcd.begin(16,2);
  45. lcd.clear();
  46. tone(buzzer,100,100);
  47. tone(buzzer,200,100);
  48. pinMode(startButton, INPUT_PULLUP);
  49. pinMode(resetButton, INPUT_PULLUP);
  50. pinMode(buzzer, OUTPUT);
  51. lcd.setCursor(0,0);
  52. lcd.print("** Ergo timer **");
  53. lcd.setCursor(0,1);
  54. lcd.print("****************");
  55.  
  56. }
  57.  
  58. void loop() {
  59.  
  60. if(digitalRead(startButton)==LOW){
  61. timerMode++;
  62. }
  63. while(timerMode==1 and countdown_time > 0){
  64.  
  65. unsigned long currentTime=millis();
  66. if (currentTime - previousTime >= eventTime){
  67. countdown_time--;
  68. lcd.clear();
  69. lcd.setCursor(0,0);
  70. lcd.print("** TOT PAUZE: **");
  71. lcd.setCursor(0, 1);
  72. lcd.print("****** ");
  73. lcd.print(countdown_time);
  74. lcd.print(" *******");
  75. previousTime=currentTime;
  76. if (countdown_time ==0 and klaar==0){
  77. lcd.clear();
  78. tone(buzzer,200,2000);
  79. lcd.setCursor(0,0);
  80. lcd.print("*** NU PAUZE ***");
  81. lcd.setCursor(0,1);
  82. lcd.print("****************");
  83. klaar++;
  84. }
  85. }
  86. }
  87.  
  88. }
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement