I am working on a calendar project using an old Vorne 2000c canned display. basically, all the display does is call up messages and can display real-time data. all through an 8-bit data port on the back. right now I am having an issue trying to figure out how to use the internal rtc on my esp32 wrover. I am simply trying to create a way where I can program the internal rtc using 3 buttons and a switch. the switch is on when I want to program the calendar. two buttons control the change, one to add whatever digits to the data and one to subtract. The final button switches between all the things that can change so minutes hours days months years. I am using a switch case for the button presses but I keep getting this rebooting error on my serial monitor, can anyone help me troubleshoot what could be wrong with my code? I also have a rtc module that is separate from the esp32 if that would work better.
later on, my plan is to have kinda a finite state machine based on the input from the rtc and have each combination be an 8-bit number that calls a message, the messages are formatted like this "Jan Sun, ^^, ^:^^ AM" the ^ are where real-time data goes which is also pulsed through the 8-bit port on the back first 4 buts are the number and next 3 are the location up to 8 digits of real-time data can be shown. is there a better approach to what I would like to do if so I am open to feed back!
#include <ESP32Time.h>
ESP32Time rtc(3600); // offset in seconds GMT+1
//input and outputs
const int addButton = 11; //button to add one
const int subButton = 10; //Button to subract one
const int progButton = 9; //Button to switch between what to program
const int progSwitch = 13;
const int pulse = 5; //Pin for the pulse signal
const int var = 6; //Pin for the Var Data signal
//const int vorneMOut[] = {7, 8, 9, 10, 11, 12, 13, 14}; //binary output for vorne display
//const int vorneDOut[] = {11, 12, 13, 14}; //binary output for data
//const int vorneLOut[] = {8, 9, 10}; //binary output for location of each data
int addButtonState = HIGH;
int subButtonState = HIGH;
int progButtonState = HIGH;
int progButtonCounter = 0;
int previousProgButtonState = HIGH;
int fieldValues[] = { 0, 0, 0, 1, 1, 2000}; //initial values for seconds, minute, hour, day#, month, year
const int currentOption = progButtonCounter; //keeps track of what option is being selected
//4 bit arrays for each digit
int min1Array[4] = {0};
int min2Array[4] = {0};
int hour1Array[4] = {0};
int hour2Array[4] = {0};
int day1Array[4] = {0};
int day2Array[4] = {0};
int year1Array[4] = {0};
int year2Array[4] = {0};
int year3Array[4] = {0};
int year4Array[4] = {0};
//time values
const unsigned long intervalTime = 1000; // time that the binary number is being sent
const unsigned long pulseTime = 900; // Time that the pulse pin is being pulsed need to be at least 10ms
void setup() {
Serial.begin(9600); // Initialize Serial Monitor
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
// Set pin modes
//for (int i = 0; i < 8; i++) {
// pinMode(vorneMOut[i], OUTPUT);
// }
// for (int i = 0; i < 4; i++) {
// pinMode(vorneDOut[i], OUTPUT);
// }
//for (int i = 0; i < 3; i++) {
// pinMode(vorneLOut[i], OUTPUT);
// }
pinMode(pulse, OUTPUT);
pinMode(var, OUTPUT);
pinMode(addButton, INPUT_PULLUP);
pinMode(subButton, INPUT_PULLUP);
pinMode(progButton, INPUT_PULLUP);
pinMode(progSwitch, INPUT_PULLUP);
}
void loop() {
if (digitalRead(progSwitch) == HIGH)
{ // Prog switch is turned on to program
if (progButtonState != previousProgButtonState)
{
if (digitalRead(progButton) == LOW)
{
progButtonCounter++;
Serial.print("Button pressed! Counter: ");
Serial.println(progButtonCounter);
}
previousProgButtonState = progButtonState; // Update the previous button state
}
if (progButtonCounter >= 5){
progButtonCounter = 0;
Serial.println("Counter reset to zero");
}
switch (progButtonCounter) {
case 0: //changing the minute
addButtonState = digitalRead(addButton); // Read the state of the button
if (addButtonState == HIGH) { // Button is pressed
Serial.println("addButton pressed!");
fieldValues[1] += 1;
delay(200); // Add a small delay to debounce the button
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
if (fieldValues[1] == 60)
fieldValues[1] = 0;
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
}
subButtonState = digitalRead(subButton); // Read the state of the button
if (subButtonState == HIGH){
Serial.println("subButton pressed!");
fieldValues[1] -= 1;
delay(200); // Add a small delay to debounce the button
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
if (fieldValues[1] == -1)
fieldValues[1] = 59;
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
}
break;
case 1: //changing the hour
addButtonState = digitalRead(addButton); // Read the state of the button
if (addButtonState == HIGH) { // Button is pressed
Serial.println("addButton pressed!");
fieldValues[2] += 1;
delay(200); // Add a small delay to debounce the button
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
if (fieldValues[2] == 25)
fieldValues[2] = 0;
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
}
subButtonState = digitalRead(subButton); // Read the state of the button
if (subButtonState == HIGH){
Serial.println("subButton pressed!");
fieldValues[2] -= 1;
delay(200); // Add a small delay to debounce the button
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
if (fieldValues[2] == -1)
fieldValues[2] = 24;
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
}
break;
case 2: //changing the day
addButtonState = digitalRead(addButton); // Read the state of the button
if (addButtonState == HIGH) { // Button is pressed
Serial.println("addButton pressed!");
fieldValues[3] += 1;
delay(200); // Add a small delay to debounce the button
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
if (fieldValues[3] == 32)
fieldValues[3] = 1;
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
}
subButtonState = digitalRead(subButton); // Read the state of the button
if (subButtonState == HIGH){
Serial.println("subButton pressed!");
fieldValues[3] -= 1;
delay(200); // Add a small delay to debounce the button
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
if (fieldValues[3] == 0)
fieldValues[3] = 31;
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
}
break;
case 3: //change the month
addButtonState = digitalRead(addButton); // Read the state of the button
if (addButtonState == HIGH) { // Button is pressed
Serial.println("addButton pressed!");
fieldValues[4] += 1;
delay(200); // Add a small delay to debounce the button
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
if (fieldValues[4] == 13)
fieldValues[4] = 1;
rtc.setTime(fieldValues[4], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
}
subButtonState = digitalRead(subButton); // Read the state of the button
if (subButtonState == HIGH){
Serial.println("subButton pressed!");
fieldValues[4] -= 1;
delay(200); // Add a small delay to debounce the button
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
if (fieldValues[4] == 0)
fieldValues[4] = 12;
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
}
break;
case 4: //changing the year
addButtonState = digitalRead(addButton); // Read the state of the button
if (addButtonState == HIGH) { // Button is pressed
Serial.println("addButton pressed!");
fieldValues[5] += 1;
delay(200); // Add a small delay to debounce the button
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
}
subButtonState = digitalRead(subButton); // Read the state of the button
if (subButtonState == HIGH){
Serial.println("subButton pressed!");
fieldValues[5] -= 1;
delay(200); // Add a small delay to debounce the button
rtc.setTime(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3], fieldValues[4], fieldValues[5]);
Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S %p"));
}
break;
}
}
}
here is the error i keep getting
Rebooting...
��'������WAdbc5\� ��Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x40081265 PS : 0x00060530 A0 : 0x800d0d95 A1 : 0x3ffb1f60
A2 : 0x0000000b A3 : 0x00000005 A4 : 0x00000000 A5 : 0x00000000
A6 : 0x00000001 A7 : 0x00000000 A8 : 0x3f400504 A9 : 0x00000000
A10 : 0xbb333301 A11 : 0x0000005c A12 : 0x00000000 A13 : 0x00002ad1
A14 : 0xffffffff A15 : 0x3ffbefb4 SAR : 0x0000001a EXCCAUSE: 0x0000001c
EXCVADDR: 0xbb333301 LBEG : 0x4008867c LEND : 0x400886c4 LCOUNT : 0x00000000
ELF file SHA256: 0000000000000000
Backtrace: 0x40081265:0x3ffb1f60 0x400d0d92:0x3ffb1f80 0x400d2bde:0x3ffb1fb0 0x4008b439:0x3ffb1fd0
Rebooting...