Loading...
Pages: [1]   Go Down
Author Topic: tempreture control code  (Read 120 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
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);
    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.





Logged

Queens, New York
Offline Offline
Edison Member
*
Karma: 31
Posts: 1730
"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.

Code:
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

UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W

"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown

Pages: [1]   Go Up
Print
 
Jump to: