Pages: [1]   Go Down
Author Topic: tempreture control code  (Read 236 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


Queens, New York
Offline Offline
Faraday Member
Karma: 106
Posts: 3766
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could try, and this is just an example, it might not work at all but it may help you find the answer.

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) {
« Last Edit: January 11, 2013, 01:46:45 pm by HazardsMind » Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Pages: [1]   Go Up
Jump to: