said
exit ststus 1
'setTime' was not declared in this scope
here is the code
#include <LiquidCrystal.h> //these are libraries that need to be downloaded from the Arduino Playground website (LiquidCrystal.h should come pre-downloaded with
#include <Time.h> //the Arduino): Arduino Playground - Time
#include <Wire.h>
int buttonPin1 = 4;
int buttonPin2 = 3;
int buttonPin3 = 2;
int buzzerPin = 13;
int tSeconds=10, tMinutes=0, hours=0; //this line, along with another line in void timerFunction(), is where you can adjust the amount of time that is counted down in //the timer function
int centiseconds=0, sSeconds=0, sMinutes=0;
int button1Counter = 0; //this section initializes the button counters, which is how the buttons can have multiple operations within the same function - more info:
int button1State = 0; // http://arduino.cc/en/Tutorial/ButtonStateChange
int lastButton1State = 0;
int button2Counter = 0;
int button2State = 0;
int lastButton2State = 0;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup()
{
lcd.begin(16, 2);
setTime(17,50,00,4,16,2017); // this is how you can set the time for the clock function (hour,minute,second,day,month,year)
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
pinMode(buttonPin3, INPUT_PULLUP);
pinMode(buzzerPin, OUTPUT);
}
void loop()
{
button1State = digitalRead(buttonPin1); //this section gives the "Mode" button the ability to have three seperate operations
if(button1State != lastButton1State)
{
if(button1State = HIGH)
{
button1Counter++;
button2Counter = 1;
delay(200);
}
}
lastButton1State = button1State;
if(button1Counter > 3)
{
button1Counter = 1;
}
button2State = digitalRead(buttonPin2); //similarly, this section allows the "Start/Stop" button the ability to have two seperate functions
if(button2State != lastButton2State)
{
if(button2State = HIGH)
{
button2Counter++;
delay (200);
}
}
lastButton2State = button2State;
if(button2Counter > 2)
{
button2Counter = 1;
}
switch(button1Counter) //switch case is really nice for changing the clock between its three functions
{
case 1: //the clock defaults to clockFunction()
lcd.clear();
lcd.setCursor(2, 1);
lcd.print(":");
lcd.setCursor(5, 1);
lcd.print(":");
clockFunction();
break;
case 2: //if the "Mode" button is pressed, clock switches to timerFunction()
lcd.clear();
lcd.setCursor(2, 1);
lcd.print(":");
lcd.setCursor(5, 1);
lcd.print(":");
timerFunction();
break;
case 3: //if "Mode" is pressed again, the clock switches once more to stopwatchFunction()
lcd.clear();
lcd.setCursor(2, 1);
lcd.print(":");
lcd.setCursor(5, 1);
lcd.print(".");
stopwatchFunction();
break;
}
}
void clockFunction() //this is the time clock function; it works using the Time.h library
{
lcd.setCursor(0, 0);
printDigits(month());
lcd.setCursor(2, 0);
lcd.print("/");
lcd.setCursor(3, 0);
printDigits(day());
lcd.setCursor(5, 0);
lcd.print("/");
lcd.setCursor(6, 0);
lcd.print(year());
lcd.setCursor(0, 1);
lcd.print(hour());
lcd.setCursor(3, 1);
printDigits(minute());
lcd.setCursor(6, 1);
printDigits(second());
delay(100);
}
void timerFunction() //the timer function was made with the help of this post: wizdum - Pastebin.com
{
if(button2Counter == 2) //if "Start/Stop" is pressed, the timer counts down
{
static unsigned long lastTick = 0;
if (tSeconds > 0)
{
if (millis() - lastTick >= 1000)
{
lastTick = millis();
tSeconds--;
lcdOutput();
}
}
if (tMinutes > 0)
{
if (tSeconds <= 0)
{
tMinutes--;
tSeconds = 60;
}
}
if (hours > 0)
{
if (tMinutes <= 0)
{
hours--;
tMinutes = 60;
}
}
}
else //if "Start/Stop" is unpressed or pressed a second time, display the current time, but don't count down
{
lcdOutput();
}
if(hours == 00 && tMinutes == 00 && tSeconds == 00) //when timer ends, the alarm goes off
{
button2Counter = 1;
while(digitalRead(buttonPin3) == HIGH) //the alarm will only go off until "Restart" is pressed
{
lcd.setCursor(0, 1);
lcd.print("00:00:00");
digitalWrite(buzzerPin, HIGH);
delay(100);
digitalWrite(buzzerPin, LOW);
delay(100);
}
if(digitalRead(buttonPin3) == LOW) //when "Restart" is pressed, the timer resets
{
hours = 0; //this part also
tMinutes = 0;
tSeconds = 10;
lcdOutput();
}
}
if(digitalRead(buttonPin3) == LOW && button2Counter == 1) //resets the timer when "Restart" button is pressed, as long as the timer is NOT running
{
hours = 0; //this part also must be changed when the timer is altered, to match the initial time
tMinutes = 0;
tSeconds = 10;
delay(10);
}
}
void stopwatchFunction()
{
lcd.setCursor(6, 1);
printDigits(centiseconds);
lcd.setCursor(3, 1);
printDigits(sSeconds);
lcd.setCursor(0, 1);
printDigits(sMinutes);
if(button2Counter == 2) //if the "Start/Stop" button is pressed, the time begins running
{
delay(5);
centiseconds++;
}
if(digitalRead(buttonPin3) == LOW && button2Counter == 1) //if the "Restart" button is pressed, as long as the timer is paused, the stopwatch resets to 00:00.00
{
centiseconds = 0;
sSeconds = 0;
sMinutes = 0;
}
if(centiseconds == 100)
{
centiseconds = 0;
sSeconds++;
}
if(sSeconds == 60)
{
sSeconds = 0;
sMinutes++;
}
}
void lcdOutput() //this is just used to display the timer on the LCD
{
lcd.setCursor(0, 1);
printDigits(hours);
lcd.setCursor(3, 1);
printDigits(tMinutes);
lcd.setCursor(6, 1);
printDigits(tSeconds);
delay(100);
}
void printDigits(int digits) //this void function is really useful; it adds a "0" to the beginning of the number, so that 5 minutes is displayed as "00:05:00", rather than "00:5 :00"
{
if(digits < 10)
{
lcd.print("0");
lcd.print(digits);
}
else
{
lcd.print(digits);
}
}