30 minutes countdown lcd 16x2

hey.. i'm new in arduino and i'm using arduino for my school project. I'm making a shoe dryer machine and there will be 4 buttons. The first button is for 30 minutes countdown. The second button is for 60 minutes countdown. The third button is for 90 minutes countdown and the last one is for emergency stop button. Can anyone help me because I can't seem to find anywhere example coding for this kind of project yet and I really don't know what to do because i've tried to do it on my own but there is tons of error..

testcoding2.ino (1018 Bytes)

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

What model Arduino do you have and can you provide a link to the spec of your LCD please.

Tom... :slight_smile:

Hi,
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

How have you got your press buttons wired?
By the looks of your code you have the buttons between 5V and the arduino input pins.
You will need 10K resistors, each one connecting an input pin to gnd, this makes sure that if the button is not pushed the input pin is pulled to gnd.
Using an input pin and leaving it open circuit, allows it to assume any value.

Hope this helps.. Tom... :slight_smile:

Hi,
I just looked at your code, what are you trying to do with the variable min ?

Tom.. :slight_smile:

i'm using arduino uno and this is the link to my lcd spec : LCD spec
I've also attach an image of an example of a circuit that is just like mine but the difference is that the keypad is switch to the 4 buttons..

Hi,
Okay, you will need to fit 10K resistors from the input pins to gnd for your application to work reliably.
I have used some of your code to tidy it up a little.
I have added the needed commands to initialise the LCD.
This code should on start up flash "hello world" on the display for 1 second.
Then blank, each time you then press one of your buttons the time interval should appear on the LCD.
Lets get this working first before getting the countdown timer operating.

#include<LiquidCrystal.h>   // declare lcd

int buttonState = 0;


const int buttonPina = 2;
const int buttonPinb = 3;
const int buttonPinc = 4;

LiquidCrystal lcd(12 , 11, 5, 4, 3, 2);  //RS , E,5(D4) ,4(D5), 2(D7)


// variables will change:
int buttonStatea = 0;         // variable for reading the pushbutton status
int buttonStateb = 0;
int buttonStatec = 0;
int buttonStated = 0;
unsigned long timer = 0;
void setup()
{

  pinMode(buttonPina, INPUT);
  pinMode(buttonPinb, INPUT);
  pinMode(buttonPinc, INPUT);
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // set the cursor to column 0, line 0
  // (note: line 0 is the first row, since counting begins with 0):
  lcd.setCursor(0, 0);
  // Print a message to the LCD.
  lcd.print("hello, world!");
  delay(1000);
  // set the cursor to column 0, line 0
  // (note: line 0 is the first row, since counting begins with 0):
  lcd.setCursor(0, 0);
  // Print blanks to blank out message
  lcd.print("                ");

}


void loop()
{

  buttonStatea = digitalRead(buttonPina);
  buttonStateb = digitalRead(buttonPinb);
  buttonStatec = digitalRead(buttonPinc);

  if (buttonStatea == HIGH)
  {
    timer = 30;
  }
  if (buttonStateb == HIGH)
  {
    timer = 60;
  }
  if (buttonStatec == HIGH)
  {
    timer = 90;
  }
  lcd.setCursor(0, 0);
  // Print a message to the LCD.
  lcd.print(timer);
}

A tip when writing your code, select TOOLS then AUTO FORMAT, this will align your code for easy reading.
Feel free to use and develop my code, I have done this to get you started.

Tom.... :slight_smile:
It compiles but I am not in a position to actually test it on a UNO, this was adapted from an LCD example in the IDE.

Thank you so much. It can compile but when I test it on my uno it doesn't come out on the LCD. The LCD only lights up but there's nothing on the screen and the buttons doesn't function..

two things, do you get Hello World when you power on ?

#2 do you have a back up UNO ?
I fear that if you try to power your relay from the Arduino pin you could burn it out.

Hi,
Have you adjusted the contrast pot on the LCD display PCB?

Tom.. :slight_smile: