iI have aan Arduino project to do , with arduino , to make anwhich requires a countdown timer (i make thatwhich I've already done) .I connect I connected a push button , and i want when I press the butonthat button I need it to increase time with 10+my countdown timer by +10 seconds. Cand
Can anyone help me with adding the code for thethis button?
thereHere is the code: so far(iI declared the button, ibut I don't know if isit's any good):
#include <LiquidCrystal.h>
int buttonPin = 7;
int buttonState = 0;
int Sseconds = 30; // count seconds
int Mminutes = 0; // count minutes
int Hhours = 0; // count hours
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
//initialize the library with the numbers of the interface pins
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); // pins connected to LCD
void setup()
{
lcd.begin(16, 2); //set up the LCD's number of columns and rows
pinMode(buttonPin, INPUT);
}
void loop()
{
buttonState = digitalRead(buttonPin);
lcd.setCursor(1, 0);
lcd.print ("Sosire in:");
lcd.setCursor(6, 1);
lcd.print(":");
lcd.setCursor(9, 1);
lcd.print(":");
S seconds--;
delay(1000);
if (S<0seconds < 0)
{
M minutes--;
S=59; seconds = 59;
}
if (M<0minutes < 0)
{
H hours--;
M=59; minutes = 59;
}
if (H<0hours < 0)
{
H=0; M=0; S=30; hours = 0;
minutes = 0;
seconds = 30;
}
if (M>9minutes > 9)
{
lcd.setCursor(7, 1);
lcd.print(Mminutes);
}
else
{
lcd.setCursor(7, 1);
lcd.print("0");
lcd.setCursor(8, 1);
lcd.print(Mminutes);
lcd.setCursor(9, 1);
lcd.print(":");
}
if (S>9seconds > 9)
{
lcd.setCursor(10, 1);
lcd.print(Sseconds);
}
else
{
lcd.setCursor(10, 1);
lcd.print("0");
lcd.setCursor(11, 1);
lcd.print(Sseconds);
lcd.setCursor(12, 1);
lcd.print(" ");
}
if (H>9hours > 9)
{
lcd.setCursor(4, 1);
lcd.print (Hhours);
}
else
{
lcd.setCursor(4, 1);
lcd.print("0");
lcd.setCursor(5, 1);
lcd.print(Hhours);
lcd.setCursor(6, 1);
lcd.print(":");
}
if (S==0seconds == 0)
{
lcd.clear();
lcd.print("Este in statie");
delay(5000);
lcd.clear();
}
}