Go Down

Topic: tempreture control code (Read 425 times) previous topic - next topic


Hi every one.
I try to do a code for mega 2560 , lcd ,buttons, ds1820.
I do this.

#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 42
OneWire oneWire(ONE_WIRE_BUS);
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
DallasTemperature sensors(&oneWire);

void setup() {

   lcd.begin(20, 4);

    void loop()
    lcd.setCursor   (    2, 3);
     lcd.print(" TEMP: ");
    lcd.print(" C ");

  It is working OK.
I found this code, and i want to set      ( (65 C)  alarm tempreture ),   with a button, for stoping  a
heater ( with rele ) .
This button must change the alarm temreture ( when it pressed for 3 sec.) up or doun.

I am looking for something like this in internet 5 days . I  found many  examples and projects, all the same  without this button.

Tell me how to do this please.


Jan 11, 2013, 07:28 pm Last Edit: Jan 11, 2013, 07:46 pm by HazardsMind Reason: 1
You could try, and this is just an example, it might not work at all but it may help you find the answer.

Code: [Select]

int timer = 0; //global var

if(ButtonUp == HIGH) {
  timer = millis();// get the current time in milliseconds, and store it.
  if((millis() - timer ) / 1000 == 3) { //Look at the new time and subtract it from the old time,
                                        //then if the difference of the two times are divisible by 1000
                                        //and equals 3 (seconds) do your function.
    //change mode, maybe use case statement
    //timer = 0; //reset timer

if(ButtonDn == HIGH) {
My GitHub:

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131