Hi all, I am new to programming arduino but I am trying to write a code that will allow users to change the date with the 'up' and 'dn' buttons and then hit the 'ok' button which will save that date. I want to be able for the arduino to store that date and send a pre-typed sms message on that date to the user but I have not been able t figure that part out. So if anyone has any suggestions they would be greatly appreciated. I continue to get an error message that certain aspects are not declared and everything I do comes back with the same error. I am using an Arduino Uno wifi board with an external RTC. Does anyone know what might be going on with my code?
/*
LiquidCrystal Library - display() and noDisplay()
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/
// include the library code:
#include <LiquidCrystal.h>
#include <RTCZero.h>
#include <Time.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2, upButtonPin = 7, dnButtonPin = 6; okButtonPin = 8;
int upButtonState = 0;
int dnButtonState = 0;
int okButtonState = 0;
int setValue = 10;
RTC_DS3231 rtc; //creates the real-time clock
DateTime now;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
const byte day = 25;
const byte month = 9;
const byte year = 15;
void setup() {
pinMode(upButtonPin, INPUT);
pinMode(dnButtonPin, INPUT);
pinMode(okButtonPin, INPUT);
// set up the LCD's number of columns and rows:
lcd.begin(4, 2);
// Print a message to the LCD.
lcd.print("Spoiler Alert");
delay(2000);
}
void loop() {
now = rtc.now(); //updates the current time
updateDisplay();
delay(500);
upButtonState = digitalRead(upButtonPin);
if (upButtonState == HIGH)
{
setValue ++;
}
dnButtonState=digitalRead(dnButtonPin);
if (dnButtonState == HIGH)
{
setValue --;
}
okButtonState=digitalRead(okButtonPin);
if (okButtonState == HIGH)
{
lcd.print(line1);
}
}
void updateDisplay(){
time_t nextMakeTime;
tm.Second = 0;
tm.Hour = 0;
tm.Minute = 0;
tm.Day = Day;
tm.Month = Month;
tm.Year = Year;
nextMakeTime = makeTime(tm); // convert time elements into time_t
Serial.println(nextMakeTime);
Serial.println(day(nextMakeTime));
Serial.println(month(nextMakeTime));
Serial.println(year(nextMakeTime));
delay(3000);
}
Moderator edit: tags