Running Two Independent Data Sets

I am trying to work with a dual sided display (one display, two sets of data). I have the whole thing working for each side individually, but I need to get the two sides to be able to run at the same time but have different parameters. I have each side activated through the Serial Monitor where a certain input activates an if statement. Is there a way to run both of these if statements at the same time, but have different start times? Like start A then when A has been running for a time be able to start B? It doesn't seem like with my set up I will be able to, but I figured someone out there might know more than I do. Thanks in advance.

#include <genieArduino.h>
Genie genie;
#include <math.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);
#define RESETLINE 4
#include "RTClib.h"
RTC_PCF8523 rtc;

const byte numChars = 5;
char receivedCharsA[numChars];
char receivedCharsB[numChars];
const byte numCharsSide = 2;
char side[numCharsSide];
boolean newDataA = false;
boolean newDataB = false;
const byte numCharsVol = 5;
char receivedCharsVolA[numCharsVol];
char receivedCharsVolB[numCharsVol];
boolean newDataVolA = false;
int LastChangedA;
int differenceA;
int cost_initialA;
boolean newDataVolB = false;
int LastChangedB;
int differenceB;
int cost_initialB;
int volA = 0;
int volB = 0;
unsigned long startTimeA = 0;
unsigned long currentTimeA = 0;
unsigned long chargeTimeA = 0;
unsigned long hourChargeA;
unsigned long minuteChargeA;
unsigned long secondChargeA;
unsigned long startTimeB = 0;
unsigned long currentTimeB = 0;
unsigned long chargeTimeB = 0;
unsigned long hourChargeB;
unsigned long minuteChargeB;
unsigned long secondChargeB;
int StartHourA = 0;
int StartMinuteA = 0;
int StartSecondA = 0;
int StartMonthA = 0;
int StartDayA = 0;
int StartYearA = 0;
int PowerA = 0;
int deliveredA = 0;
int costA = 0;
int costB = 0;
int deliveredB = 0;
int StartMonthB = 0;
int StartHourB = 0;
int StartMinuteB = 0;
int StartSecondB = 0;
int StartDayB = 0;
int StartYearB = 0;
int PowerB = 0;
int salesTax = 6350;
int fullFee = 2000;
int sessionCap = 6000;
int overstayFee = 500;
int energyPrice = 0;
int timeFee = 5;
int pluginFee = 10;
int idleFee = 50;
int sessionLimitHour = 2;
int sessionLimitMinute = 0;
int offPeakFirst = 9;
int peakFirst = 110;
int timeYear;
int timeMonth;
int timeDay;
int timeHour;
int timeMinute;
int timeSecond;
boolean SideSet = false;
int numSide;
boolean peakSet = false;
boolean peakSetting = false;
char isPeak[numCharsSide];
int costA_disp;
int costB_disp;

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
  mySerial.begin(9600);
  genie.Begin(mySerial);

#ifndef ESP8266
  while (!Serial);
#endif

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    Serial.flush();
    abort();
  }

  pinMode(RESETLINE, OUTPUT);
  digitalWrite(RESETLINE, 1);
  delay(100);
  digitalWrite(RESETLINE, 0);
  delay(3500);
  initializeDisplay();
  delay(1000);
  Serial.println("Charging Ready\n");
  Serial.println("Peak or Off Peak?");
}

void loop() {
  if (peakSet == false) {
    getPeak();
    getTimeNow();
  }
  else {
    if (peakSet == false && SideSet == false) {
      Serial.println("ERROR");
      getTimeNow();
    }
    else {
      recvWithEndMarkerA();
      showNewDataA();
      getTimeNow();
    }
  }
  if (SideSet == false && peakSet == true) {
    getSide();
    getTimeNow();
  }
  else {
    if (volA == 0 && volB == 0 && SideSet == false && peakSet == true) {
      Serial.println("No Active Side");
      getTimeNow();
    }
    else {
      recvWithEndMarkerA();
      showNewDataA();
      getTimeNow();
    }
  }
  if (side[0] == 'A' || side[0] == 'a') {
    if (volA == 0) {
      getVolumeA();
      getTimeNow();
    }
    else {
      if (energyPrice == 0 && newDataVolA == false) {
        Serial.print("Charge Needed: ");
        Serial.println(volA);
        getTimeNow();
      }
      else {
        recvWithEndMarkerA();
        showNewDataA();
        getTimeNow();
      }
    }
    if (energyPrice > 0 && volA > 0) {
      startTimeA = millis();
      getTimeNow();
      countChargeA();
      getTimeNow();
      delay(500);
      getTimeNow();
      resetAllA();
    }
    else {
      recvWithEndMarkerA();
      showNewDataA();
      getTimeNow();
    }
  }
  if (side[0] == 'B' || side[0] == 'b') {
    if (volB == 0) {
      getVolumeB();
      getTimeNow();
    }
    else {
      if (energyPrice == 0 && newDataVolB == false) {
        Serial.print("Charge Needed: ");
        Serial.println(volB);
        getTimeNow();
      }
      else {
        recvWithEndMarkerB();
        showNewDataB();
        getTimeNow();
      }
    }
    if (energyPrice > 0 && volB > 0) {
      startTimeB = millis();
      getTimeNow();
      countChargeB();
      getTimeNow();
      delay(500);
      getTimeNow();
      resetAllB();
    }
    else {
      recvWithEndMarkerB();
      showNewDataB();
      getTimeNow();
    }
  }
}

void getPeak() {
  static byte ndx = 0;
  char endMarker = '\n';
  char peak_read;

  while (Serial.available() > 0 && peakSet == false) {
    peak_read = Serial.read();

    if (peak_read != endMarker) {
      isPeak[ndx] = peak_read;
      ndx++;
      if (ndx >= numCharsSide) {
        ndx = numCharsSide - 1;
      }
    }
    else {
      isPeak[ndx] = '\0';
      ndx = 0;
      peakSet = true;
    }
  }
  if (peakSet == true) {
    if (isPeak[0] == 'p' || isPeak[0] == 'P') {
      genie.WriteStr(0, "PEAK");
      Serial.println("PEAK");
      peakSetting = true;
    }
    if (isPeak[0] == 'o' || isPeak[0] == 'O') {
      genie.WriteStr(0, "OFF PEAK");
      Serial.println("OFF PEAK");
      peakSetting = false;
    }
    Serial.println("Which side?");
  }
}

void getSide() {
  static byte ndx = 0;
  char endMarker = '\n';
  char side_read;

  while (Serial.available() > 0 && SideSet == false) {
    side_read = Serial.read();

    if (side_read != endMarker) {
      side[ndx] = side_read;
      ndx++;
      if (ndx >= numCharsSide) {
        ndx = numCharsSide - 1;
      }
    }
    else {
      side[ndx] = '\0';
      ndx = 0;
      SideSet = true;
    }
  }
  if (SideSet == true) {
    if (side[0] == 'A' || side[0] == 'a') {
      genie.WriteObject(GENIE_OBJ_USER_LED, 0, 1);
    }
    if (side[0] == 'B' || side[0] == 'b') {
      genie.WriteObject(GENIE_OBJ_USER_LED, 1, 1);
    }
    Serial.print("Side ");
    Serial.print(side);
    Serial.println(" Active\n");
    Serial.print("How much charge on ");
    Serial.print(side);
    Serial.println("?");
  }
}

void getVolumeA() {
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0, StartHourA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 1, StartMinuteA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 2, StartSecondA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 3, StartMonthA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 4, StartDayA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 5, StartYearA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 6, PowerA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 7, deliveredA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 8, costA);
  static byte ndx = 0;
  char endMarker = '\n';
  char vol_readA;
  while (Serial.available() > 0 && newDataVolA == false) {
    vol_readA = Serial.read();
    if (vol_readA != endMarker) {
      receivedCharsVolA[ndx] = vol_readA;
      ndx++;
      if (ndx >= numCharsVol) {
        ndx = numCharsVol - 1;
      }
    }
    else {
      receivedCharsVolA[ndx] = '\0';
      ndx = 0;
      newDataVolA = true;
    }
  }
  if (newDataVolA == true) {
    Serial.print("Charge required on A is ");
    Serial.print(receivedCharsVolA);
    Serial.println("0 watt-hours\n");
    volA = atoi(receivedCharsVolA);
    if (volA > sessionCap) {
      volA = sessionCap;
      Serial.print("Session Cap is ");
      Serial.println(sessionCap);
      Serial.print("Charge required on A is now ");
      Serial.print(volA);
      Serial.println("0 watt-hours\n");
    }
    //Serial.println(vol);
    Serial.println("How much does it cost?");
  }
}

void getVolumeB() {
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 9, costB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 10, deliveredB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 11, StartMonthB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 12, StartHourB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 13, StartMinuteB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 14, StartSecondB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 15, StartDayB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 16, StartYearB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 17, PowerB);
  static byte ndx = 0;
  char endMarker = '\n';
  char vol_readB;
  while (Serial.available() > 0 && newDataVolB == false) {
    vol_readB = Serial.read();
    if (vol_readB != endMarker) {
      receivedCharsVolB[ndx] = vol_readB;
      ndx++;
      if (ndx >= numCharsVol) {
        ndx = numCharsVol - 1;
      }
    }
    else {
      receivedCharsVolB[ndx] = '\0';
      ndx = 0;
      newDataVolB = true;
    }
  }
  if (newDataVolB == true) {
    Serial.print("Charge required on B is ");
    Serial.print(receivedCharsVolB);
    Serial.println("0 watt-hours\n");
    volB = atoi(receivedCharsVolB);
    if (volB > sessionCap) {
      volB = sessionCap;
      Serial.print("Session Cap is ");
      Serial.println(sessionCap);
      Serial.print("Charge required on B is now ");
      Serial.print(volB);
      Serial.println("0 watt-hours\n");
    }
    Serial.println("How much does it cost?");
  }
}

void recvWithEndMarkerA() {
  static byte ndx = 0;
  char endMarker = '\n';
  char rcA;

  while (Serial.available() > 0 && newDataA == false && newDataVolA == true) {
    rcA = Serial.read();

    if (rcA != endMarker) {
      receivedCharsA[ndx] = rcA;
      ndx++;
      if (ndx >= numChars) {
        ndx = numChars - 1;
      }
    }
    else {
      receivedCharsA[ndx] = '\0';
      ndx = 0;
      newDataA = true;
    }
    getTimeNow();
  }
  getTimeNow();
}

void recvWithEndMarkerB() {
  static byte ndx = 0;
  char endMarker = '\n';
  char rcB;

  while (Serial.available() > 0 && newDataB == false && newDataVolB == true) {
    rcB = Serial.read();

    if (rcB != endMarker) {
      receivedCharsB[ndx] = rcB;
      ndx++;
      if (ndx >= numChars) {
        ndx = numChars - 1;
      }
    }
    else {
      receivedCharsB[ndx] = '\0';
      ndx = 0;
      newDataB = true;
    }
    getTimeNow();
  }
  getTimeNow();
}

void showNewDataA() {
  if (newDataA == true) {
    Serial.print("Price Changed at ");
    Serial.print(deliveredA);
    Serial.println("0 watt-hours on A");
    Serial.print("New price is ");
    energyPrice = atoi(receivedCharsA);
    Serial.print(energyPrice);
    Serial.println(" cents\n");
    genie.DoEvents();
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 22, energyPrice);
    newDataA = false;
    LastChangedA = deliveredA;
    Serial.println("Has the price changed?");
    getTimeNow();
  }
}

void showNewDataB() {
  if (newDataB == true) {
    Serial.print("Price Changed at ");
    Serial.print(deliveredB);
    Serial.println("0 watt-hours on B");
    Serial.print("New price is ");
    energyPrice = atoi(receivedCharsB);
    Serial.print(energyPrice);
    Serial.println(" cents\n");
    genie.DoEvents();
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 22, energyPrice);
    newDataB = false;
    LastChangedB = deliveredB;
    Serial.println("Has the price changed?");
    getTimeNow();
  }
}

void calcTimeA() {
  currentTimeA = millis();
  chargeTimeA = currentTimeA - startTimeA;
  hourChargeA = floor(chargeTimeA / 3600000);
  if (hourChargeA < 1) {
    minuteChargeA = floor(chargeTimeA / 60000);
  }
  else {
    minuteChargeA = floor((chargeTimeA - (hourChargeA * 3600000)) / 60000);
  }
  if (minuteChargeA < 1 && hourChargeA < 1) {
    secondChargeA = floor(chargeTimeA / 1000);
  }
  else {
    secondChargeA = floor((chargeTimeA - (hourChargeA * 3600000) - (minuteChargeA * 60000)) / 1000);
  }

  if (hourChargeA == sessionLimitHour && minuteChargeA == sessionLimitMinute) {
    Serial.println("Session Limit Reached on A");
    delay(500);
    resetAllA();
  }
  getTimeNow();
  if (chargeTimeA < 1000) {
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0, timeHour);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 1, timeMinute);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 2, timeSecond);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 3, timeMonth);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 4, timeDay);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 5, timeYear);
  }
}

void calcTimeB() {
  currentTimeB = millis();
  chargeTimeB = currentTimeB - startTimeB;
  hourChargeB = floor(chargeTimeB / 3600000);
  if (hourChargeB < 1) {
    minuteChargeB = floor(chargeTimeB / 60000);
  }
  else {
    minuteChargeB = floor((chargeTimeB - (hourChargeB * 3600000)) / 60000);
  }
  if (minuteChargeB < 1 && hourChargeB < 1) {
    secondChargeB = floor(chargeTimeB / 1000);
  }
  else {
    secondChargeB = floor((chargeTimeB - (hourChargeB * 3600000) - (minuteChargeB * 60000)) / 1000);
  }
  if (hourChargeB == sessionLimitHour && minuteChargeB == sessionLimitMinute) {
    Serial.println("Session Limit Reached on B");
    delay(500);
    resetAllB();
  }
  getTimeNow();
  if (chargeTimeB < 1000) {
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 12, timeHour);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 13, timeMinute);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 14, timeSecond);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 11, timeMonth);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 15, timeDay);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 16, timeYear);
  }
}

void countChargeA() {
  for (deliveredA = 0; deliveredA < (volA + 1); deliveredA++) {
    recvWithEndMarkerA();
    showNewDataA();
    differenceA = deliveredA - LastChangedA;
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 7, deliveredA);
    if (deliveredA > 300) {
      if (differenceA == deliveredA) {
        costA = cost_initialA + ((deliveredA - 300) * energyPrice * 0.01L);
      }
      if (differenceA == 0 && differenceA != deliveredA) {
        cost_initialA = costA;
      }
      if (differenceA >= 0 && differenceA != deliveredA) {
        costA = cost_initialA + ((differenceA + 1) * energyPrice * 0.01L);
      }
    }
    if (deliveredA <= 300 && peakSetting == true) {
      costA = peakFirst * deliveredA * 0.01L;
      cost_initialA = peakFirst * 3;
      LastChangedA = 300;
    }
    if (deliveredA <= 300 && peakSetting == false) {
      costA = offPeakFirst * deliveredA * 0.01L;
      LastChangedA = 300;
      cost_initialA = offPeakFirst * 3;
    }
    costA_disp = (costA + ceil(timeFee * chargeTimeA / 3600000) + pluginFee) * ((salesTax * 0.00001) + 1);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 8, costA_disp);
    calcTimeA();
    getTimeNow();
    delay(500);
  }
}

void countChargeB() {
  for (deliveredB = 0; deliveredB < (volB + 1); deliveredB++) {
    recvWithEndMarkerB();
    showNewDataB();
    differenceB = deliveredB - LastChangedB;
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 10, deliveredB);
    if (deliveredB > 300) {
      if (differenceB == deliveredB) {
        costB = cost_initialB + ((deliveredB - 300) * energyPrice * 0.01L);
      }
      if (differenceB == 0 && differenceB != deliveredB) {
        cost_initialB = costB;
      }
      if (differenceB >= 0 && differenceB != deliveredB) {
        costB = cost_initialB + ((differenceB + 1) * energyPrice * 0.01L);
      }
    }
    if (deliveredB <= 300 && peakSetting == true) {
      costB = peakFirst * deliveredB * 0.01L;
      cost_initialB = peakFirst * 3;
      LastChangedB = 300;
    }
    if (deliveredB <= 300 && peakSetting == false) {
      costB = offPeakFirst * deliveredB * 0.01L;
      LastChangedB = 300;
      cost_initialB = offPeakFirst * 3;
    }
    costB_disp = (costB + ceil(timeFee * chargeTimeB / 3600000) + pluginFee) * ((salesTax * 0.00001) + 1);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 9, costB_disp);
    calcTimeB();
    getTimeNow();
    delay(500);
  }
}

void resetAllA() {
  deliveredA = 0;
  costA = 0;
  LastChangedA = 0;
  differenceA = 0;
  cost_initialA = 0;
  volA = 0;
  startTimeA = 0;
  currentTimeA = 0;
  chargeTimeA = 0;
  hourChargeA = 0;
  minuteChargeA = 0;
  secondChargeA = 0;
  StartHourA = 0;
  StartMinuteA = 0;
  StartSecondA = 0;
  StartMonthA = 0;
  StartDayA = 0;
  StartYearA = 0;
  newDataVolA = false;
  peakSet = false;
  SideSet = false;
  side[0] = "c";
  genie.WriteObject(GENIE_OBJ_USER_LED, 0, 0);
  Serial.println("\nNew Charging Session on A");
  Serial.println("Peak or Off Peak?");
  getTimeNow();
}

void resetAllB() {
  deliveredB = 0;
  costB = 0;
  LastChangedB = 0;
  differenceB = 0;
  cost_initialB = 0;
  volB = 0;
  newDataVolB = false;
  peakSet = false;
  SideSet = false;
  side[0] = "c";
  genie.WriteObject(GENIE_OBJ_USER_LED, 1, 0);
  Serial.println("\nNew Charging Session on B");
  Serial.println("Peak or Off Peak?");
  getTimeNow();
}

void initializeDisplay() {
  genie.WriteContrast(10);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0, StartHourA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 1, StartMinuteA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 2, StartSecondA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 3, StartMonthA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 4, StartDayA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 5, StartYearA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 6, PowerA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 7, deliveredA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 8, costA);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 9, costB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 10, deliveredB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 11, StartMonthB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 12, StartHourB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 13, StartMinuteB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 14, StartSecondB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 15, StartDayB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 16, StartYearB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 17, PowerB);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 18, salesTax);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 19, fullFee);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 20, sessionCap);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 21, overstayFee);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 22, energyPrice);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 23, timeFee);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 24, pluginFee);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 25, idleFee);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 26, sessionLimitHour);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 27, sessionLimitMinute);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 28, offPeakFirst);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 29, peakFirst);
  genie.WriteObject(GENIE_OBJ_USER_LED, 0, 0);
  genie.WriteObject(GENIE_OBJ_USER_LED, 1, 0);
  getTimeNow();
}

void getTimeNow() {
  DateTime now = rtc.now();
  timeYear = now.year();
  timeMonth = now.month();
  timeDay = now.day();
  timeHour = now.hour();
  timeMinute = now.minute();
  timeSecond = now.second();
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 30, timeHour);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 31, timeMinute);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 32, timeSecond);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 33, timeMonth);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 34, timeDay);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 35, timeYear);
}

Which Arduino are you using that makes you even think it can do two things at the same time?
Paul

Why?

I don't understand your problem. What is the observed bahaviour?

What is a side?

Just a thing that I noticed in your code. You have several receive routines; in principle you should only have one; your code will know what it is used for. I suggest that you use just the original receiveWithEndmarker() and determine in the other code what needs to happen.

You should also separate any user interface (display) related code from the receive code.

Like I said, I don't think I can, but I wanted to see if someone else know if I could. Anyway, I am using an Uno.

This code is for a dual charger. Each side needs to be able to be activated independently and potentially at different times and for different lengths of time.

I have an A "side" or set of data and a B "side". I can activate each side on its own, but not one side while the other is already running. So say A is 2 minutes into running and then I need to activate B to start at 0, I cannot do that.

What do you mean by this? I just used this code from an example I found and it is what gets the new price data when a price needs to be changed on the display and in the calculations (energyPrice in my code). This code receives several different things (peak or off peak, which side, price) in different functions I have written.

Here is a picture of my display if it helps to visualize what I am doing.

To learn how to do "several things at the same time" with Arduino, study this tutorial.

That all makes sense and is great, but doesn't help in this situation. I don't have a specified time when it will need to start. And within each of my if statements, I have a function which contains a for loop that will run for hours if that's what is necessary (testing with incrementing from 0 to 6000 with a 500ms delay between each. This runs for about an hour). That is the main chunk of the program. While that for loop is running is when I would need to activate the other if statement.

The issues I'm seeing with this and why I don't think it will work are:
(1) the serial monitor is actively looking for a price change, so putting in a letter to activate the side would screw it up and
(2) side[numCharsSide] is a character array that stores either 'A' or 'B' (which then activates the respective set of data) and changing that would pull it out of the the current function it was running.

Like I have said, I don't think it is possible to do what I would like it to, which is fine. I was just hoping I was wrong and that someone else knew more than I did.

All you want is likely to be possible, but cannot be something that is added after the program is written. You have to design the whole program so it will work that way.
Paul

I am willing to do this, I just don't know how to get it to work. Would I be able to use what I have as a baseline, or would I need to totally rewrite it?

Total rewrite, beginning with a flow chart to be sure your logic is correct.
Paul

What display is that (link, if commercial or)?

For whom is this software being created? How did you convince them to let you try?

a7

Okay thank you, I will work on that

Link to the display:

I am working on this for the company I am interning at. No convincing necessary. They just need a prototype. Leaving it to me to determine capabilities. Although I don't know why that is important.

Abject curiosity, sry. That is a fine display, kudos on getting it to work however you have been successful so far…

And it seems entirely within reach of the hardware you are using to get it fully up and running. But I agree that starting over having that goal in mind will be the best approach, perhaps after you have embraced the usual ways such problems are solved.

No doubt some of your lower level code can be used directly or repurposed, but the overall structure will change, probably substantially.

Look for some examples of doing several things at once, perhaps someone has already or will point you at the ones commonly offered here. Simple examples demonstrating the basic ideas. Establish a framework you are comfortable working within and take small steps utilising it.

Good luck with your internship!

a7

I didn't mean to come off as rude, so sorry if I did :slight_smile: . I am just trying to be careful about how much I release to the public since this is for a company and is kind of sensitive info.

Thank you for your input and guidance!

No worries. I will own coming off as rude, just another grumpy old man, honestly envious and living vicariously through the trials and tribulations of noobs and their ilk.

You already not a noob, TBC. :expressionless:

a7

1 Like