Those are the only parts of code I added in when it stopped working, so I didn't include it all. It is very long and most of it is irrelevant to the time issues, but here it is.
#include <genieArduino.h>
Genie genie;
#include <math.h>
#include <Time.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2,3);
#define RESETLINE 4
const byte numChars=5;
char receivedChars[numChars];
boolean newData=false;
const byte numCharsVol=5;
char receivedCharsVol[numCharsVol];
boolean newDataVol=false;
long int price=0;
long int delivered=0;
long int cost=0;
int LastChanged;
int difference;
int cost_initial;
int vol=0;
unsigned long startTime;
unsigned long currentTime;
unsigned long chargeTime;
long int hourCharge;
long int minuteCharge;
long int secondCharge;
int timeHour;
int timeMin;
int timeMonth;
int timeDay;
void setup() {
Serial.begin(9600);
while(!Serial){
;
}
mySerial.begin(9600);
genie.Begin(mySerial);
pinMode(RESETLINE, OUTPUT);
digitalWrite(RESETLINE, 1);
delay(100);
digitalWrite(RESETLINE, 0);
delay(3500);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,8,0);
genie.WriteContrast(10);
timeHour = hour();
timeMin = minute();
timeMonth = month();
timeDay = day();
genie.WriteObject(GENIE_OBJ_LED_DIGITS,3,timeHour);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,4,timeMin);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,5,timeMonth);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,6,timeDay);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,7,82);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,11,999);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,12,59);
delay(1000);
Serial.println("Charging Ready\n");
Serial.println("How much charge?");
}
void loop() {
timeHour = hour();
timeMin = minute();
timeMonth = month();
timeDay = day();
genie.WriteObject(GENIE_OBJ_LED_DIGITS,3,timeHour);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,4,timeMin);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,5,timeMonth);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,6,timeDay);
if(vol==0){
getVolume();
}
else{
if(price==0&&newDataVol==false){
Serial.print("Charge Needed: ");
Serial.println(vol);
}
else{
recvWithEndMarker();
showNewData();
}
}
if(price>0 && vol>0){
startTime=millis();
timeHour = hour();
timeMin = minute();
timeMonth = month();
timeDay = day();
genie.WriteObject(GENIE_OBJ_LED_DIGITS,3,timeHour);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,4,timeMin);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,5,timeMonth);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,6,timeDay);
for(delivered=0;delivered<(vol+1);delivered++){
timeHour = hour();
timeMin = minute();
timeMonth = month();
timeDay = day();
genie.WriteObject(GENIE_OBJ_LED_DIGITS,3,timeHour);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,4,timeMin);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,5,timeMonth);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,6,timeDay);
recvWithEndMarker();
showNewData();
difference=delivered-LastChanged;
//Serial.println(LastChanged);
//Serial.println(delivered);
//Serial.println(difference);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,1,delivered);
if(difference==delivered){
cost = difference*price*0.01L;
//Serial.println("first one");
}
if(difference==0 && difference != delivered){
cost_initial = cost;
//Serial.println("second one");
//Serial.println(cost_initial);
}
if(difference>=0 && difference != delivered){
cost = cost_initial+((difference+1)*price*0.01L);
//Serial.println("third one");
}
//Serial.println(cost);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,2,cost);
currentTime=millis();
chargeTime = currentTime-startTime;
hourCharge = floor(chargeTime/3600000);
if(hourCharge<1){
minuteCharge = floor(chargeTime/60000);
}
else{
minuteCharge = (chargeTime-(hourCharge*3600000))/1000;
}
if(minuteCharge<1){
secondCharge = chargeTime/1000;
}
else{
secondCharge = (chargeTime-(minuteCharge*60000))/1000;
}
genie.WriteObject(GENIE_OBJ_LED_DIGITS,9,hourCharge);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,10,minuteCharge);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,13,secondCharge);
delay(300);
}
timeHour = hour();
timeMin = minute();
timeMonth = month();
timeDay = day();
genie.WriteObject(GENIE_OBJ_LED_DIGITS,3,timeHour);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,4,timeMin);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,5,timeMonth);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,6,timeDay);
delay(30000);
timeHour = hour();
timeMin = minute();
timeMonth = month();
timeDay = day();
genie.WriteObject(GENIE_OBJ_LED_DIGITS,3,timeHour);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,4,timeMin);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,5,timeMonth);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,6,timeDay);
price=0;
delivered=0;
cost=0;
LastChanged=0;
difference=0;
cost_initial=0;
vol=0;
hourCharge=0;
minuteCharge=0;
secondCharge=0;
newDataVol=false;
genie.WriteObject(GENIE_OBJ_LED_DIGITS,0,price);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,1,delivered);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,2,cost);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,9,hourCharge);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,10,minuteCharge);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,13,secondCharge);
Serial.println("\nNew Charging Session");
Serial.println("How much charge?");
timeHour = hour();
timeMin = minute();
timeMonth = month();
timeDay = day();
genie.WriteObject(GENIE_OBJ_LED_DIGITS,3,timeHour);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,4,timeMin);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,5,timeMonth);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,6,timeDay);
}
else{
recvWithEndMarker();
showNewData();
}
}
void getVolume(){
static byte ndx=0;
char endMarker = '\n';
char vol_read;
while(Serial.available()>0 && newDataVol==false){
vol_read = Serial.read();
if(vol_read != endMarker){
receivedCharsVol[ndx]=vol_read;
ndx++;
if(ndx>=numCharsVol){
ndx=numCharsVol-1;
}
}
else{
receivedCharsVol[ndx]='\0';
ndx=0;
newDataVol=true;
}
}
if(newDataVol==true){
Serial.print("Charge required is ");
Serial.print(receivedCharsVol);
Serial.println("0 watt-hours\n");
vol = atoi(receivedCharsVol);
//Serial.println(vol);
Serial.println("How much does it cost?");
}
}
void recvWithEndMarker(){
static byte ndx=0;
char endMarker = '\n';
char rc;
while(Serial.available()>0 && newData==false && newDataVol==true){
rc=Serial.read();
if(rc != endMarker){
receivedChars[ndx]=rc;
ndx++;
if(ndx>=numChars){
ndx=numChars-1;
}
}
else{
receivedChars[ndx]='\0';
ndx=0;
newData=true;
}
}
}
void showNewData(){
if(newData==true){
Serial.print("Price Changed at ");
Serial.print(delivered);
Serial.println("0 watt-hours");
Serial.print("New price is ");
price = atoi(receivedChars);
Serial.print(price);
Serial.println(" cents\n");
genie.DoEvents();
genie.WriteObject(GENIE_OBJ_LED_DIGITS,0,price);
newData = false;
LastChanged = delivered;
Serial.println("Has the price changed?");
}
}
Error Message (exact paths are not accurate because I cannot post my company name online):
Arduino: 1.8.15 (Windows 10), Board: "Arduino Uno"
C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\----\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10815 -build-path C:\Users\--~1\AppData\Local\Temp\arduino_build_772662 -warnings=none -build-cache C:\Users\--~1\AppData\Local\Temp\arduino_cache_204491 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\----\Desktop\change_price_with_serial\change_price_with_serial_3\change_price_with_serial_3.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\----\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10815 -build-path C:\Users\--~1\AppData\Local\Temp\arduino_build_772662 -warnings=none -build-cache C:\Users\--~1\AppData\Local\Temp\arduino_cache_204491 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\----\Desktop\change_price_with_serial\change_price_with_serial_3\change_price_with_serial_3.ino
Using board 'uno' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "C:\\Users\\--~1\\AppData\\Local\\Temp\\arduino_build_772662\\sketch\\change_price_with_serial_3.ino.cpp" -o nul
Alternatives for genieArduino.h: [ViSi-Genie-Arduino-Library-master@1.5.1 genieArduino-1.5.2@1.5.2]
ResolveLibrary(genieArduino.h)
-> candidates: [ViSi-Genie-Arduino-Library-master@1.5.1 genieArduino-1.5.2@1.5.2]
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Users\\--\\--\\Documents\\Arduino\\libraries\\genieArduino-1.5.2\\src" "C:\\Users\\--~1\\AppData\\Local\\Temp\\arduino_build_772662\\sketch\\change_price_with_serial_3.ino.cpp" -o nul
Alternatives for SoftwareSerial.h: [SoftwareSerial@1.0]
ResolveLibrary(SoftwareSerial.h)
-> candidates: [SoftwareSerial@1.0]
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Users\\--\\--\\Documents\\Arduino\\libraries\\genieArduino-1.5.2\\src" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SoftwareSerial\\src" "C:\\Users\\--~1\\AppData\\Local\\Temp\\arduino_build_772662\\sketch\\change_price_with_serial_3.ino.cpp" -o nul
Using cached library dependencies for file: C:\Users\----\Documents\Arduino\libraries\genieArduino-1.5.2\src\genieArduino.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp
Generating function prototypes...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Users\\--\\--\\Documents\\Arduino\\libraries\\genieArduino-1.5.2\\src" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SoftwareSerial\\src" "C:\\Users\\--~1\\AppData\\Local\\Temp\\arduino_build_772662\\sketch\\change_price_with_serial_3.ino.cpp" -o "C:\\Users\\--~1\\AppData\\Local\\Temp\\arduino_build_772662\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\--~1\\AppData\\Local\\Temp\\arduino_build_772662\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Users\\--\\--\\Documents\\Arduino\\libraries\\genieArduino-1.5.2\\src" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SoftwareSerial\\src" "C:\\Users\\---~1\\AppData\\Local\\Temp\\arduino_build_772662\\sketch\\change_price_with_serial_3.ino.cpp" -o "C:\\Users\\---~1\\AppData\\Local\\Temp\\arduino_build_772662\\sketch\\change_price_with_serial_3.ino.cpp.o"
C:\Users\----\Desktop\change_price_with_serial\change_price_with_serial_3\change_price_with_serial_3.ino: In function 'void setup()':
change_price_with_serial_3:47:16: error: 'hour' was not declared in this scope
timeHour = hour();
^~~~
change_price_with_serial_3:48:15: error: 'minute' was not declared in this scope
timeMin = minute();
^~~~~~
C:\Users\----\Desktop\change_price_with_serial\change_price_with_serial_3\change_price_with_serial_3.ino:48:15: note: suggested alternative: 'init'
timeMin = minute();
^~~~~~
init
change_price_with_serial_3:49:17: error: 'month' was not declared in this scope
timeMonth = month();
^~~~~
change_price_with_serial_3:50:15: error: 'day' was not declared in this scope
timeDay = day();
^~~
C:\Users\----\Desktop\change_price_with_serial\change_price_with_serial_3\change_price_with_serial_3.ino: In function 'void loop()':
change_price_with_serial_3:64:15: error: 'hour' was not declared in this scope
timeHour = hour();
^~~~
change_price_with_serial_3:65:15: error: 'minute' was not declared in this scope
timeMin = minute();
^~~~~~
C:\Users\----\Desktop\change_price_with_serial\change_price_with_serial_3\change_price_with_serial_3.ino:65:15: note: suggested alternative: 'init'
timeMin = minute();
^~~~~~
init
change_price_with_serial_3:66:17: error: 'month' was not declared in this scope
timeMonth = month();
^~~~~
change_price_with_serial_3:67:15: error: 'day' was not declared in this scope
timeDay = day();
^~~
Multiple libraries were found for "genieArduino.h"
Used: C:\Users\----\Documents\Arduino\libraries\genieArduino-1.5.2
Not used: C:\Users\----\Documents\Arduino\libraries\ViSi-Genie-Arduino-Library-master
Using library genieArduino-1.5.2 at version 1.5.2 in folder: C:\Users\----\Documents\Arduino\libraries\genieArduino-1.5.2
Using library SoftwareSerial at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial
exit status 1
'hour' was not declared in this scope