Puppy Timer for Walks, please help

Got my son a puppy but he's sort of young, 12, I'd like him to have a timer that tells him to walk the pup. I'd like to teach him responsibility and while I thought based on online countdown timers that this would be easier I'm now stuck on an error and the pup is nearly 16 weeks the walks are really starting to make a difference, hard to keep up with a lab!

I don't want my son stuck on his video games so hopefully this litter timer can get him and the pup into a good routine.

//puppy timer, remember 1000 millis = 1 second

#include <LiquidCrystal.h>
#include <Tone.h>

//initialize the library with the number of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

Tone tone1 = 8;    //sets piezo outpin pin as a tone output

int startButton = 10;  //start switch on digital pin 10
int start = 1024;      //value for storage of start button

int hours1 = 2;        //timer1 variable to display hours on lcd
int minutes1 = 30;      //timer1 variable to display minutes on lcd
int seconds1 = 0;      //timer1 variable to display seconds on lcd
int totalseconds1 = 0;  //total time of timer1

int hours2 = 0;        //timer2 variable to display hours on lcd
int minutes2 = 15;      //timer2 variable to display minutes on lcd
int seconds2 = 0;      //timer2 variable to display seconds on lcd
int totalseconds2 = 0;  //total time of timer2

int msg = 0;          //value for the welcome message

void setup()
{
  // put your setup code here, to run once:
  //set up the LCD's number of column and rows:
  lcd.begin(16,2);
  
  pinMode(tone1, OUTPUT);    //sets pin 8 as piezo output
  pinMode(startButton, INPUT);  //sets pin 10 as start input
  
  msg = 0;            //value of welcome message
  start = 1024;      //value of start button
  
  
}

void loop()
{
  // put your main code here, to run repeatedly:
  if(msg==0)      //show the welcome message only 1 time
  {
    lcd.setCursor(0,0);
    lcd.print("Puppy Walk");
    lcd.setCursor(0,1);
    lcd.print("Schedule for me");
    delay(2500);
    msg = 2;
    lcd.clear();
  }
  
 do
{
 
 //begins
 
 lcd.setCursor(0,0);

    lcd.print("");      //if hours are less than 10, put a zero in front
    lcd.print(hours1);    //without this code, it'll show as H:M:S (1:M:S)
    lcd.print(":");
    
    lcd.print("");      //if minutes are less than 10, put zero in front
    lcd.print(minutes1);  //without this code, it'll show as H:M:S (H:1:S)
    lcd.print(":");
  
  if (seconds1 < 10) lcd.print("0");  //if seconds are less than 10, put zero in front
    lcd.print(seconds1);              //without this code, it'll show as H:M:1
    
    start = digitalRead(startButton);    //reads start button
    
    if (start == 0)                    //if the start button was pressed...
    {
      totalseconds1 = seconds1 + (minutes1 * 60) + (hours1 * 60 * 60);    //converts time to seconds
    }
    
      if (totalseconds1 == 0) 
        lcd.clear();
        lcd.setCursor(0,0);
        
          lcd.print("");
          lcd.print(hours2);
          lcd.print(":");
        
          lcd.print("");
          lcd.print(minutes2);
          lcd.print(":");
        
          if (seconds2 < 10) lcd.print("0");
            lcd.print(seconds2);
          
            {
              totalseconds2 = seconds2 + (minutes2 * 60) + (hours2 * 60 * 60);
            
            } 
                          
} while(start != 0);    //menu of preset time repeats until button is pressed

//Once the button has been pressed, it goes into next while and won't finalize until end

  while (totalseconds1 > 0)
  {
    delay (1000);    //decrement in periods of 1 second
    totalseconds1--;
    
    hours1 = ((totalseconds1 / 60)/ 60);  //converts total seconds into hours
    minutes1 = (totalseconds1 / 60) % 60; //converts total seconds into minutes
    seconds1 = totalseconds1 % 60;        //converts total seconds into periods of 60 seconds
    
    lcd.setCursor(0,0);
    lcd.print("Next walk in...");        //we display timer remaining message
    
    lcd.setCursor(4,1);
    if (hours1 < 10) lcd.print("0");  //if hours are less than 10, put a zero in front of it
    lcd.print(hours1);
    lcd.print(":");
    
    if (minutes1 < 10) lcd.print("0");
    lcd.print(minutes1);
    
    if (seconds1 < 10) lcd.print("0");
    lcd.print(seconds1);
    
      if (totalseconds1 == 0)        //time block 1 has finalized
      {
          while(1)
          {
              lcd.clear();
              lcd.setCursor(5,0);
              lcd.print("Walk the puppy!");
              lcd.setCursor(3,1);
              lcd.print("15 Minutes");
              
              tone1.play(400, 600);
              delay(100);
              tone1.play(587, 300);
              delay(100);
             
          }
      }
  }
  while (totalseconds2 > 0)
  {
    delay (1000);      //decrementation of periods by 1 second for timer2
    totalseconds2--;
    
    hours2 = ((totalseconds2 / 60)/ 60);
    minutes2 = (totalseconds2 / 60) % 60;
    seconds2 = totalseconds2 % 60;
    
    lcd.setCursor(0,0);
    lcd.print("Walk dog for");
    
    lcd.setCursor(4,1);
    if (hours2 < 10) lcd.print("0");
    lcd.print(hours2);
    lcd.print(":");
    
    if (minutes2 < 10) lcd.print("0");
    lcd.print(minutes2);
    lcd.print(":");
    
    if (seconds2 < 10) lcd.print("0");
    lcd.print(seconds2);
    
      if (totalseconds2 == 0)
      {
        while(1)
        {
            lcd.clear();
            lcd.setCursor(5,0);
            lcd.print("Next walk in...");
            lcd.setCursor(3,1);
            lcd.print("2 hrs 30 mins");
            
            tone1.play (400, 600);
            delay(100);
            tone1.play (587, 300);
            delay(100);
        }
      }
  }
  
}

I don't understand why I'm getting this error:

Special_Timer_Sketch2:9: error: conversion from 'int' to non-scalar type 'Tone' requested
Special_Timer_Sketch2.ino: In function 'void setup()':
Special_Timer_Sketch2:32: error: cannot convert 'Tone' to 'uint8_t' for argument '1' to 'void pinMode(uint8_t, uint8_t)'

I'd like the timer to run as follows:

Turned on with a switch

Start button for the countdown to begin (each day we wakes up we'll hit this to begin timing the day's walks)

2 hour and 30 minute countdown
15 minute countdown (pup is being walked)
2 hour and 30 minute countdown again
15 minute countdown (pup is being walked)

at the end of each countdown i'd like it to sound the piezo speaker with a tone then go on to the next countdown.

I'm willing to pay if necessary and am hoping to finish before he's out of school next friday. Thanks for your time in advance.

You are using the Tone library incorrectly

At the start of the code use:-

Tone tone1;    //sets piezo outpin pin as a tone output

not what you did:-

Tone tone1 = 8;

Then in the setup function change:-

//  pinMode(tone1, OUTPUT);    //do not use this line replace it with:-
   tone1.begin(8);

Finally this library is a bit old. To fix it edit the Tone.ccp file
Change where it says:-
#include <wiring.h>
To
#include <Arduino.h>

Then it will compile.

miggsp:
Got my son a puppy but he's sort of young, 12,

So not really a puppy then....

:wink:

My son is 12, the puppy is about 16 weeks old

Thanks, this has helped me greatly. The issue now is it won't continue into the second timer. I will continue to see if I'm missing something.

Use serial print statements to see where the code is going and values of variables at points in the code. You can track down where and why your flow is going wrong.

Grumpy_Mike:
Use serial print statements to see where the code is going and values of variables at points in the code. You can track down where and why your flow is going wrong.

Thanks a lot Grumpy Mike, finally understand what you meant, months and months later :smiley: :blush:

I got into Arduino and general electronics because of this project and have really enjoyed the journey despite the puppy timer never working as I had hoped, all due to my own lack of knowledge of course. I've been using the Evil Genius books, some intro Arduino books and a college textbook for the Electronics 1 course I'm taking at my local community college.

I didn't want to bring up this old thread but did so to thank you and JimboZA for replying to my thread and helping me out. I hope to contribute to this community and learn a lot, the latter heavily outweighing the former for a good while for sure.

I'm doing basic projects from my books and hoping to complete the puppy timer soon and upload my project here for all to use. I figure by then I can an RTC DS1307 and microSD shield to add some time stamping and data logging to it.

miggsp:
thank you and JimboZA for replying to my thread and helping me out.

Not that I helped at all.... Puppy must be 18 months or so now? Probably taking your son for walks....

There's loads of stuff around on DS1307 and sd card logging, so pretty sure you'll have little problem there.

The pup is fully grown now although he still acts like a pup. The pup is often with me as I work from home now.

Yea I'm actually messing around with it now. I got the puppy timer to run in a very basic manner, not sure how good it is but it did help some. I could never get it to show the count down timer properly but I did get it to ring a siren so it was able to alert my son and even me, to take out the dog for his walk and even added a notification to have the pup fed his meals timely and then be taken out 45 mins after.

Not sure if anyone would have use for this but I'll be completing it so I don't have to run if off a pack of rechargeable AAs anymore. I've been working with Li-Ion 18650s and 7805 VRs so I can easily use that method to power it for longer periods.

I'm working on adding that DS1307 and sd card logging plus putting it in an enclosure so i can actually say it's a complete project now haha

One thing I did find was that Low Battery Warning Kit from SparkFun using the TL431 Shunt Regulator. They were low on kits so I was only able to order one, I went ahead and noticed it was damn easy to rebuild with my own components. I ordered a 10pk of TL431s and have since got it working to show a low battery warning at 25% using a DMM to set the 10K Pot. That has helped me tremendously and it's actually very easy to install on a battery-powered project.

Best one I have seen recently was on Facebook where there was a sign posted in the house that read something like "for today's wifi password, complete these tasks:" - posted where the kids had to complete the tasks to get the password for the day (I wish I had thought of that!!)

If you want a decent (and reasonably priced) book on electronics, take a look at "Practical Electronics for Inventors" (Amazon carries it here ).

You know, it's the 2nd time I have that book recommended to me, I'll definitely have to pick it up.