01-11-2021, 14:49
Witam dopiero się uczę potrzebuję zmienić przycisk aby włączał stoper kiedy jest wciśnięty a zatrzymywał i resetował kiedy jest puszczony
//#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>
#define button 1
int buttonPushCounter = 0;
bool bPress = false;
int nalewaki = 6;
int timerMode = 0;
long startTime;
long stopTime;
LiquidCrystal_I2C lcd(0x27,20,4);
void setup(){
lcd.init();
lcd.backlight();
lcd.begin(16, 2);
lcd.clear();
pinMode(button, INPUT_PULLUP);
lcd.print("Stoper:");
}
void loop(){
lcd.setCursor(16, 2);
if (digitalRead(button) == LOW){
startTime = millis();
timerMode++;
delay(400);
}
if (timerMode == 1){
lcd.setCursor(7, 0);
lcd.print((millis() - startTime) / 1000.0);
}
if (timerMode > 1){
delay(2000);
timerMode = 0;
lcd.clear();
lcd.print("Stoper:");
}
}
//#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>
#define button 1
int buttonPushCounter = 0;
bool bPress = false;
int nalewaki = 6;
int timerMode = 0;
long startTime;
long stopTime;
LiquidCrystal_I2C lcd(0x27,20,4);
void setup(){
lcd.init();
lcd.backlight();
lcd.begin(16, 2);
lcd.clear();
pinMode(button, INPUT_PULLUP);
lcd.print("Stoper:");
}
void loop(){
lcd.setCursor(16, 2);
if (digitalRead(button) == LOW){
startTime = millis();
timerMode++;
delay(400);
}
if (timerMode == 1){
lcd.setCursor(7, 0);
lcd.print((millis() - startTime) / 1000.0);
}
if (timerMode > 1){
delay(2000);
timerMode = 0;
lcd.clear();
lcd.print("Stoper:");
}
}