General question

hi, i have a question, if anyone could help, i am constructing an egg incubator for a friend. the atmega328 is controlling a 12v fan, a 24v lamp with pwm to automatically set the temp to a desired level, and uses a SHT1x sensor for getting temp and humidity readings, displayed onto a 16x2 lcd. the desired temp to be achieved is programed onto the atmega (between 37 & 38) and after that it is fixed. is there a way for me to incorporate 2 buttons in the design (a + and a -) and while the circuit is on, and the lcd displays the measurements, by pressing the buttons, to be able to set a new level of temp to be reached? hope this makes sense

Yes, that's no problem. Just read the buttons along the rest of the things you do in your loop function and avoid using the delay function and use millis() instead if you need to wait for a time.

Korman

thanx for the reply, in the loop function a have a delay of 10s at the end this is required as the the sensor reads the temp, the lamp is adjusted via pwm and a have to wait to see the change in temperature.

i am looking into interrupts...

is it the right way to go? any suggestions?

cheers from greece

i am looking into interrupts…
is it the right way to go?

There’s no need for interrupts in this case. It’s just enough that you avoid the delay function. How to do that is best described in the Blink without delay tutorial.

Korman

i suppose i have to avoid the delay() because i might miss a button being pushed. i dont get the idea with millis()... but i managed to get it to work with interrupts! but i am using both available (atmega328) for each button.

You really don't need interrupts for this application. The blink without delay tutorial should point you in the right direction

i dont get the idea with millis()...

It's like checking your watch if an hour is already over. You really should understand that tutorial, the technique explained there is essential in many situations.

Korman

thank u for your time guys, if u say so, i will look into it... am still a beginer, so every input is well received.. cheers