I am working on a little project where i want to use a LCD displayed timer you can increase by 10 sec when you press a button.
It’s supost to work like this:
Press button 3x —> LCD displays 30sec —> press button timer start —> Timer counts down on LCD —> when timer = 0 —> switch relay.
I currently use this bit of code to add 10 sec to my timer but i want to change the value of the timer to increase 10000 at one time and not by repeating the same code 10000 times each time i want to add 10 sec to my timer.
if( b_Timerup==HIGH )
{
for(int i = 0; i<10000; i++) {
Timer ++;
}
}
I haven’t tested the code yet and i don’t have a 10k linear potentiometer for the LCD Display does somewane know if i can use a resistor instead?
My full this far code:
#include <LiquidCrystal.h>
const int b_Timerup = 22; //Set time up 10 sec
const int b_Timerreset = 23; //Reset timer
const int b_Timerstart = 24; //Starts timer
const int b_Timerstop = 25; //Stops Timer
const int Relay = 26; //Switch Relay
const int LED_Timer = 40; //Timer on LED
//LCD
const int d7 = 2;
const int d6 = 3;
const int d5 = 4;
const int d4 = 5;
const int en = 11;
const int rs = 12;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int Timer = 0; //Timer Amount
void setup() {
pinMode (b_Timerup,INPUT);
pinMode (b_Timerreset,INPUT);
pinMode (b_Timerstop,INPUT);
pinMode (Relay,OUTPUT);
pinMode (LED_Timer,OUTPUT);
lcd.begin(16, 2);
lcd.print("Welcome Dovah");
}
void loop() {
//Timer
if( b_Timerup==HIGH )
{
for(int i = 0; i<10000; i++) {
Timer ++;
}
}
if( b_Timerreset==HIGH )
{
digitalWrite(Relay, LOW);
Timer = 0;
//LCD display "Timer reset"
}
if( b_Timerstart==HIGH )
{
digitalWrite(LED_Timer, HIGH);
delay(Timer);
//LCD display "count down in sec"
digitalWrite(Relay, HIGH);
}
}