I want to make a program where if the temperature reach 30° a DC motor turns on for 5 sec and then even If the temperature keeps at 30° that the motor dont turn on again.
the problem with the programI have is that if the temperature is at 30° the motor turns on for 5 sec but if the temperature keeps 30° the motor keeps turned On
Sorry, but my crystal ball has crashed again and my mind-reading powers aren't working, so I cannot see your code.
Post your code here, between code tags (the "</>" button above the posting window) so that we can see where you are going wrong.
Add a flag variable that is set when the motor is turned on.
test to see if it has been set before turning motor on.
bool motorHasRun = false; // flag variable
void setup() { }
void loop() {
if (temp > tempThreshold && motorHasRun == false){ // test temp and flag
digitalWrite (motor,HIGH); // example motor run code
motorHasRun = true; // set flag so motor can't run more than once
}
}
if you need to reset it so the motor can run again you can do something like:
if (temp < tempThreshold){ // some condition that that will trigger reset
motorHasRun = false; // reset flag
}