#define ntemp 10
float temps[ntemp];
void setup() {
Serial.begin(115200);
// initialise the random number generator with a seed
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() {
delay(5000)
;}