I need to control the temperature on my bbq pit smoker. If it goes too hot, i can use a baffle to close the exhaust vent. The hotter it gets, the more I close the vent. I’ve designed and built an Arduino control that uses a thermocouple to detect the oven temperature and an rc servo to close and open the baffle as needed. I do it in 4 steps. Each time the temperature goes to a higher range, the servo closes the baffle another 25%. This is set up to maintain 225° and the servo control works perfectly.
I won’t always want to maintain 225°. Let’s say that I want to maintain 300°. How would I do that without going in and changing the code? A pot would be nice, but I have no idea how to do that. A push button that would toggle through different temperature selections would be nice too , especially if an led would indicate what range was selected. Please give me some ideas and solutions.
// *****************************************************************************
// This program works for adjusting Servo based on temperature detected
// *****************************************************************************
#include "max6675.h"
int temp;
int thermoDO = 4;
int thermoCS = 5;
int thermoCLK = 6;
int Servoangle1(0); // Radial degrees defined position - 85-100
int Servoangle2(45); // Radial degrees defined position - 101-120
int Servoangle3(90); // Radial degrees defined position - 121-130
int Servoangle4(135); // Radial degrees defined position - 134-140
int Servoangle5(180); // Radial degrees defined position - 141-150
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int pos = 100; // variable to store the servo position
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
void setup() {
Serial.begin(9600);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
//temp = (thermocouple.readFahrenheit()-9);
temp = (thermocouple.readFahrenheit());
if (temp <= 100) {
myservo.write(Servoangle1); //100% Open
Serial.println("Temp is < 100");
}
Serial.println(temp);
delay(1000);
if (temp >= 101 & temp <= 120) {
myservo.write(Servoangle2); //75% Open
Serial.println("Temp in 101-120 range");
}
Serial.println(temp);
delay(1000);
if (temp >= 121 & temp <= 130) {
myservo.write(Servoangle3); //50% Open
Serial.println("Temp in 121-130 range");
}
Serial.println(temp);
delay(1000);
if (temp >= 131 & temp <= 140) {
myservo.write(Servoangle4); //25% Open
Serial.println("Temp in 101-120 range");
}
Serial.println(temp);
delay(1000);
if (temp >= 141) {
myservo.write(Servoangle5); //0% Open
Serial.println("Temp is > 141");
}
Serial.println(temp);
delay(1000);
}type or paste code here
