#define ntemp 10
float temps [ntemp];
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
randomSeed(millis());
//populate temps array with random values between 19.5 and 22.5
for (int i=0; i < ntemp; i++){
temps[i] = random(195,226) / 10.0;
Serial.print("Temperature at index ");
Serial.print(i);
Serial.print(": ");
Serial.println(temps[i]);
}
float threshold = 21.5;
bool thresholdExceeded = false;
//check if any temperature exceeds the threshold
for (int i=0; i< ntemp; i++) {
if (temps[i] > threshold){
thresholdExceeded = true;
}
}
if (thresholdExceeded) {
Serial.println("Threshold temperature has been exceeded.");
}else{
Serial.println("Threshold temperature has not been exceeded.");
}
}
void loop() {
// put your main code here, to run repeatedly:
delay(5000); // this speeds up the simulation
}