Hi. Thank you for your responses.
So what I'd like to happen is I am implementing this code:
void ACShutterMainLoop() {
digitalWrite(enterButtonState, LOW);
digitalWrite(exitButtonState, LOW);
digitalWrite(setupButtonState, LOW);
int i=1;
while(i) {
delay(200);
enterButtonState = digitalRead(enterButton);
exitButtonState = digitalRead(exitButton);
if (enterButtonState == HIGH) {
Serial.print("Enter Button pressed :) \n ");
int totaltime;
do {
digitalWrite(TurnONLED, HIGH);
delay(TurnOnTime * 1000);
digitalWrite(TurnONLED, LOW);
digitalWrite(TurnOFFLED, HIGH);
delay(TurnOffTime * 1000);
digitalWrite(TurnOFFLED,LOW);
totaltime = totaltime + TurnOnTime + TurnOffTime;
Serial.print("\nTotal Time:");
Serial.print(totaltime);
Serial.print("\n");
} while(totaltime + TurnOnTime + TurnOffTime <= ShutterDuration);
i = 0;
delay(5000);
}
else if (exitButtonState == HIGH) {
Serial.print("Exit to Temp Monitoring\n");
i = 0;
delay(2000);
TempMonitorLoop();
}
else {
idleCounter = idleCounter++;
Serial.print("Idle Timer: ");
Serial.print(idleCounter);
Serial.print("\n");
delay(1000);
if (idleCounter == 60){
Serial.print("Idle Time reached maximum.\n");
TempMonitorLoop();
}
else{
i = 1;
}
}
}
}
... while this is happening on the background:
void TempMonitorLoop() {
int b = 1;
while (b) {
delay(200);
TempSensorVal = analogRead(TempSensorPin);
delay(100);
temp = ((((TempSensorVal / 1024) * 5) - 0.5) * 100);
lcd.begin(16, 2);
lcd.print("Temp is: ");
lcd.print(temp);
if (temp <= temparray[0])
{
// lcd.setCursor(0,1);
// lcd.print("Cool Temp");
Serial.print(temp);
Serial.print(" => Cool Temp\n");
analogWrite(10, 0); //analogwrite(PIN,Value)
}
else if (temp >= temparray[0] && temp <= temparray[1])
{
Serial.print(temp);
Serial.print(" => Ambient Temp\n");
analogWrite(10, 50);
}
else if (temp >= temparray[1] && temp <= temparray[2])
{
Serial.print(temp);
Serial.print(" => Humid Temp\n");
analogWrite(10, 100);
}
else if (temp >= temparray[2] && temp <= temparray[3])
{
Serial.print(temp);
Serial.print(" => Hot Temp\n");
analogWrite(10, 180);
}
else if (temp >= temparray[3])
{
Serial.print(temp);
Serial.print(" => hot hot Temp\n");
analogWrite(10, 254);
}
setupButtonState = digitalRead(setupButton);
delay(200);
if (setupButtonState == HIGH) {
SetUpLoop();
b = 0;
}
else {
b = 1;
}
delay(5000);
}
}