Go Down

Topic: variable temperature controller with AD595 and LCD(2x16) (Read 3526 times) previous topic - next topic


I have the schematic. Does anybody have PID code for same? I would like to vary setpoint with up/down switches.


I don't have any info on your device, but I'm doing essentially the same thing with my brewing thermostat. Here's the code, but there is more stuff in the topic itself.

Code: [Select]
#include <LiquidCrystal.h>

int des = 20;           //set temperature variable
int lastdes = 0;
int tempc = 0;          //temperature variable
int Counter1 = 0;       // counter for the number of button presses
int Counter2 = 0;       // counter for the number of button presses
int State1 = 0;         // current state of the button
int State2 = 0;         // current state of the button
int lastState1 = 0;     // previous state of the button
int lastState2 = 0;
int val = 0;

int pin = 1;            //LM35 input
const int set1 = 1;     //temp up and temp down buttons
const int set2 = 2;
int heat = 0;           //output to heater control
int indicate = 4;       //visual indicator output

LiquidCrystal lcd(8, 9, 10, 11, 12, 13);   // initialize the library with the numbers of the interface pins

void setup() {
  lcd.begin(16, 2);
  lcd.print("SET: ACT: HEAT?");  // Print headings to the LCD.
  pinMode(heat, OUTPUT);
  pinMode(indicate, OUTPUT);
  pinMode(set1, INPUT);
  pinMode(set2, INPUT);


void loop() {
State1 = digitalRead(set1);
  State2 = digitalRead(set2); 
  if (State1 != lastState1) {
        if (State1 == HIGH && des!= 100) {      //if up button is pressed, add 1 to des
  if (State2 != lastState2) {  //if down button is pressed, subtract 1 from des
       if (State2 == HIGH && des != 0) {
  tempc = (100* (long)analogRead(pin)/1024.0);  //save temperature reading as 'tempc'
  delay(1);                                     //gives a range of about 30
  lcd.setCursor(1, 1);
  lcd.print("    ");     //clear field
  lcd.setCursor(1, 1);
  lcd.print(des);     //print set temperature
  lcd.print("  ");    //clear field
  lcd.print(tempc );  //print actual temperature
  if(tempc <= des){                 //if actual temperature is less than
    digitalWrite(heat, HIGH);       //or equal to the set temperature, turn the heater on
    digitalWrite(indicate, HIGH);
    lcd.print("ON ");
  else  if(tempc > des){             //otherwise leave the heater off
    digitalWrite(heat, LOW);
    digitalWrite(indicate, LOW);


That code looks just what I need. Thanks a million!


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