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.
#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.
analogReference(INTERNAL);
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
des++;
}
}
if (State2 != lastState2) { //if down button is pressed, subtract 1 from des
if (State2 == HIGH && des != 0) {
des--;
}
}
analogRead(pin);
delay(10);
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
delay(50);
lcd.setCursor(6,1);
lcd.print(" "); //clear field
lcd.setCursor(6,1);
lcd.print(tempc ); //print actual temperature
delay(50);
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.setCursor(11,1);
lcd.print("ON ");
delay(50);
}
else if(tempc > des){ //otherwise leave the heater off
digitalWrite(heat, LOW);
digitalWrite(indicate, LOW);
lcd.setCursor(11,1);
lcd.print("OFF");
}
}
That code looks just what I need. Thanks a million!
brushless.
brushless:
I have the schematic. Does anybody have PID code for same? I would like to vary setpoint with up/down switches.
Do you have a copy of the schematic and did it work with the code below as I would like to make one and where did you get your sensor please.
Many thanks Bob
Hi I second BBBOB, do you have the Schematic hookup for switches etc.
bowlerhatman:
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.#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.
analogReference(INTERNAL);
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
des++;
}
}
if (State2 != lastState2) { //if down button is pressed, subtract 1 from des
if (State2 == HIGH && des != 0) {
des--;
}
}
analogRead(pin);
delay(10);
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
delay(50);
lcd.setCursor(6,1);
lcd.print(" "); //clear field
lcd.setCursor(6,1);
lcd.print(tempc ); //print actual temperature
delay(50);
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.setCursor(11,1);
lcd.print("ON ");
delay(50);
}
else if(tempc > des){ //otherwise leave the heater off
digitalWrite(heat, LOW);
digitalWrite(indicate, LOW);
lcd.setCursor(11,1);
lcd.print("OFF");
}
}
please post schematics.
Thanks.