#include <LiquidCrystal.h>
#include <Stepper.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
int currentStep = 0;
int stepUp = 50;
int stepDown = -50;
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 6, 5, 4, 3);
void setup() {
lcd.begin(16, 2);
// you can now interact with the LCD, e.g.:
// set the speed at 60 rpm:
myStepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
const float BETA = 3950; // should match the Beta Coefficient of the thermistor
int analogValue = analogRead(A0);
float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
lcd.begin(16, 2);
lcd.print("Temp:");
lcd.print(celsius);
lcd.print("C");
lcd.setCursor(0,2);
lcd.print("Damper%:");
lcd.print(currentStep);
delay(2000);
if(celsius > 75)
{
lcd.setCursor(8,1);
lcd.println("Adjust");
myStepper.step(50);
currentStep = stepUp + currentStep;
delay(5000);
}
if(celsius < 40)
{
lcd.setCursor(0,1);
lcd.println("Adjust");
myStepper.step(-50);
currentStep = stepDown + currentStep;
delay(5000);
}
}