Go Down

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

SERET

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);
    sensors.begin();
    }

    void loop()
      {
     sensors.requestTemperatures();
    lcd.setCursor   (    2, 3);
     lcd.print(" TEMP: ");
    lcd.print(sensors.getTempCByIndex(0));
    lcd.print(" C ");
    delay(1000);
    }

  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.






HazardsMind

#1
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) {
.
.
.
}
Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Go Up