Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ARDUINO CODE
- // libraries toevoegen //
- #include <Wire.h>
- #include <Keypad.h>
- #include <LiquidCrystal.h>
- // de lcd en de buzzer instellen //
- LiquidCrystal lcd(A0,A1,A2,A3,A4,A5);
- // de keypad instellen //
- const byte ROWS=4;
- const byte COLS=4;
- char hexaKeys[ROWS][COLS]={
- {'1','2','3','A'},
- {'4','5','6','B'},
- {'7','8','9','C'},
- {'*','0','#','D'}
- };
- byte rowPins[ROWS]={9,8,7,6};
- byte colPins[COLS]={5,4,3,2};
- Keypad customKeypad= Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
- char customKey = customKeypad.getKey();
- // variabelen instellen //
- int timerMode=0;
- int countdown_time=10;
- int reset=0;
- int klaar=0;
- const byte buzzer=12;
- const byte startButton=13;
- const byte resetButton=12;
- unsigned long eventTime=1000;
- unsigned long previousTime=0;
- // leuk symbolen instellen //
- // setup //
- void setup() {
- lcd.begin(16,2);
- lcd.clear();
- tone(buzzer,100,100);
- tone(buzzer,200,100);
- pinMode(startButton, INPUT_PULLUP);
- pinMode(resetButton, INPUT_PULLUP);
- pinMode(buzzer, OUTPUT);
- lcd.setCursor(0,0);
- lcd.print("** Ergo timer **");
- lcd.setCursor(0,1);
- lcd.print("****************");
- }
- void loop() {
- if(digitalRead(startButton)==LOW){
- timerMode++;
- }
- while(timerMode==1 and countdown_time > 0){
- unsigned long currentTime=millis();
- if (currentTime - previousTime >= eventTime){
- countdown_time--;
- lcd.clear();
- lcd.setCursor(0,0);
- lcd.print("** TOT PAUZE: **");
- lcd.setCursor(0, 1);
- lcd.print("****** ");
- lcd.print(countdown_time);
- lcd.print(" *******");
- previousTime=currentTime;
- if (countdown_time ==0 and klaar==0){
- lcd.clear();
- tone(buzzer,200,2000);
- lcd.setCursor(0,0);
- lcd.print("*** NU PAUZE ***");
- lcd.setCursor(0,1);
- lcd.print("****************");
- klaar++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement