//Serial monitor reading
//https://www.circuitbasics.com/how-to-read-user-input-from-the-arduino-serial-monitor/
int temp = 24;
int Rh = 55;
int pressure = 32;
int menuChoice;
int question = 1;
void setup() {
Serial.begin(9600);
Serial.println("1. Temperature");
Serial.println("2. Humidity");
Serial.println("3. Barometric Pressure");
}
void loop() {
if (Serial.available() == 0 && question == 1) {
Serial.println("");
Serial.println("Which sensor would you like to read?");
question = 0;
}
menuChoice = Serial.parseInt();
if (menuChoice == 1) {
// temp sensor code goes here
Serial.print("The temperature is: ");
Serial.println(temp);
question = 1;
}
if (menuChoice == 2) {
// humidity sensor code goes here
Serial.print("The humidity is: ");
Serial.println(Rh);
question = 1;
}
if (menuChoice == 3) {
// pressure sensor code goes here
Serial.print("The barometric pressure is: ");
Serial.println(pressure);
question = 1;
}
if (menuChoice != 1 && menuChoice != 2 && menuChoice != 3 && menuChoice != 0) {
Serial.println("Please choose a valid selection. Valid choices are from 1 to 3.");
question = 1;
}
}