Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
- #define button 2
- int timerMode = 0;
- long startTime;
- void setup() {
- lcd.init();
- lcd.init();
- lcd.backlight();
- lcd.setCursor(0, 0);
- lcd.print("Press To Start");
- pinMode(button, INPUT);
- }
- void loop() {
- lcd.setCursor(0, 1);
- if (digitalRead(button) == HIGH) {
- startTime = millis();
- timerMode++;
- delay(400);
- }
- if (timerMode == 1) {
- lcd.setCursor(0, 1);
- lcd.print((millis() - startTime) / 1000.0);
- }
- if (timerMode > 1) {
- delay(2000);
- timerMode = 0;
- lcd.clear();
- lcd.setCursor(0,0);
- lcd.print("Press To Start");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement