Hello, I am working on a school project to water 8 plants automatically. So far, the code is great and serves its purpose. But when the user finishes the conversation, closes the serial monitor that was used to talk, and opens it again, the conversation just doesn't save into the monitor. So, I need help finding a way for the serial monitor to save the conversations and keep them there even when the monitor is closed.
int motor = 7;
float dayset = 0; // Change to float for decimal input
unsigned long daycal = 0;
bool isOn = false; // Use a boolean variable for true/false states
int dayspass = 0;
int timethatdidpass;
void setup() {
Serial.begin(9600);
pinMode(motor, OUTPUT);
Serial.println("Hello, welcome to David's Aqua Bionic. Please insert the number of days for the cycle.");
}
void loop() {
if (!isOn) {
// Wait for user input
while (Serial.available() == 0) {}
dayset = Serial.parseFloat(); // Use parseFloat to handle decimal values
daycal = (unsigned long)(dayset * 24 * 60 * 60 * 1000); // Convert days to milliseconds
Serial.println("Ok, loading...");
delay(2000);
Serial.print("Time set in Arduino time (milliseconds): ");
Serial.println(daycal);
Serial.println("Loading again...");
delay(3000);
Serial.println("Thanks for waiting! The Aqua Bionic is ready for use now. If you need help, ask David. (Side note when you type log you need to wait until the day passed and the log will be showed))");
isOn = true; // Set the flag to indicate the system is ready
} else {
// Default motor schedule
delay(2000);
Serial.println("We have passed the else stage");
// Check if the user entered "log" while waiting for the motor cycle
if (Serial.available() > 0) {
String command = Serial.readStringUntil('\n');
if (command == "log") {
Serial.println("Welcome to the log, here is the information that we have gathered:");
timethatdidpass = daycal * dayspass*1000; // Corrected to use dayspass and added semicolon
delay(2000);
Serial.println(timethatdidpass);
}
}
delay(daycal);
digitalWrite(motor, HIGH);
Serial.println("High");
dayspass = dayspass + 1;
Serial.println(dayspass);
delay(16000);
Serial.println("Low");
digitalWrite(motor, LOW);
}
}