Timing and LCD help - first project

Hi All,

Firstly thank you for taking the time to read this!

I am attempting my first Arduino project, and it should in theory be a simple one (do I say that nievely?)

The attached diagram will hopefully give an indication of what I’m trying to achieve; have an overall power switch, which once on the LCD display will come on.
This LCD will display time minutes:seconds set by the potentiometer and count down.

This will instantly start the motor and heater from their relay motors, and stay on for the duration of the time set, then switch off as the countdown reaches zero (Shown on LCD).

I have an Arduino Uno board, and have practiced using a relay motor and switch to start / stop the motor, but from there on I’m very much looking for guidance.

Any help with the sketch or anything you are able to provide would be greatly appreciated.

Thank you ever so much,

Kind Regards,

Annie

I can't open your link. Are you sure that album is shared with public?

I too se a message saying:-

You cannot access this album

Any chance of putting it on a photo sharing site that actually allows you to share photos.

Setting time by a pot is not normal but could be done.

Grumpy_Mike:
Setting time by a pot is not normal but could be done.

I agree. Maybe the OP wants to use minimal code to do a human machine interaction. It’s not very accurate of easy to adjust but will work. Then maybe the OP can move on to using menus and buttons to control the value of a delay or count down timer much like what I just managed to do with my phi-menu;

http://arduino.cc/forum/index.php/topic,54823.msg396845.html#msg396845

A menu and input panel is what I would end up doing if I took on a similar project.

Good Evening,

I do apologise, I didn't realise that was a locked source. Here's the image:

Ahh, okay, I was not aware this wasn't a usual task, but again any help you can provide would be much appreciated.

Have browsed through the Phi-menu link, wow, great work! Although I am unsure how I would go from buttons to an analogue dial.

Are there any similar 'sketches' I have missed on the learn pages I have missed?

Thanks all, kind regards,

Annie.

here is the code i have made so far

/* Map an analog value to 8 bits (0 to 255) */

#include <LiquidCrystal.h>	    // lib. for LCD
int val = analogRead(0);
int time = 0;

int realtime = (time*1000);          //sets time to be in seconds
int second=0, minute=0;              // sets time variables
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);  // pins connected to LCD




void setup()                        // all this only happens once at startup Jennie

{
Serial.begin(9600);
pinMode(9, OUTPUT);                  // connect relay input to pin 9
lcd.begin(16,2);			 // open the LCD
lcd.setCursor(2,0);                    // set cursor to print half-way along 1st line
lcd.print("Coffee Thing");
delay(1000);
lcd.setCursor(0,1);                    // set cursor to beginning of 2nd line
lcd.print("by Jennie Morley");
delay(4000);
lcd.clear();                        // clear scree

}


void loop(){
{int val = 0;
int time = 0;
}  
val = analogRead(0);{


if (val <= 128)                        // if val is less then or equal to 128 then
{
time = 30;                          // set time at 30
lcd.setCursor(0,0);		    // sets cursor to 1st line
lcd.print ("30 Seconds");
Serial.print (val);
delay(1000);
lcd.clear();
second=30, minute=0;
countdown();
}

else if (val <= 256 > 129)            // if val is less then or equal to 256 then
{
time = 60;                    // set time at 60
lcd.setCursor(0,0);		    // sets cursor to 1st line
lcd.print ("1 Minute");
Serial.print (val);
delay(1000);
lcd.clear();
second=0, minute=1;
countdown();
}



if (val <= 512 > 257)           // if val is less then or equal to 512 then
{
time = 120;                      // set time at 120
lcd.setCursor(0,0);		    // sets cursor to 1st line
lcd.print ("2 Minutes");
Serial.print (val);
delay(1000);
lcd.clear();
second=0, minute=2;
countdown();
}


if (val <= 1024 > 513)         // if val is less then or equal to 1024 then
{
time = 240;                      // set time at 240
lcd.setCursor(0,0);		    // sets cursor to 1st line
lcd.print ("4 Minutes");
Serial.print (val);
delay(1000);
lcd.clear();
second=0, minute=4;
countdown();
}

digitalWrite (9, LOW);               //turn motor relay on  
delay (realtime);                       // delay set time              
digitalWrite (9, HIGH);             // turn motor relay off
  }
}

void countdown(){
  
  static unsigned long lastTick = 0; 
  if (second > 0) {
      if (millis() - lastTick >= 1000) {
          lastTick = millis();
          second--;
          serialOutput();
      }
  }
 
 // decrement one minute every 60 seconds
  if (minute > 0) {
      if (second <= 0) {
          minute--;
          second = 60; // reset seconds to 60
      }
  }
}

void serialOutput() {
  {
  lcd.setCursor(0,1);
  lcd.print("Time left: ");
  lcd.print(minute, DEC); // the minute, sent to the screen in decimal format
  lcd.print(":"); // a colon between the minute and the second
  lcd.println(second, DEC); // the second, sent to the screen in decimal format
  lcd.clear();
//termination condition
  }
}//close serialOutput();

at the moment it will read from the variable resistor ok, goes to the 30 seconds but wont go from that if statment, if the input becomes greater than 128 the screen goes blank.
Also it wont go to the countdown sub routine at all.

Any help and advise would be greatly appreciated.

Thank you Annie xx

void loop(){
{int val = 0;
int time = 0;
}

Create two variable, initialise them, then destroy them.
Not useful.
Get rid of the braces.

else if (val <= 256 > 129)

That needs two comparisons against “val” with &&

else if (val <= 256 && val > 129)

“image non disponible”