#include <Stepper.h>
// Define the number of steps per revolution for the stepper motor
const int steps_per_revolution = 200;
// Define the pins for the stepper motor
const int motor_pin1 = 8;
const int motor_pin2 = 9;
const int motor_pin3 = 10;
const int motor_pin4 = 11;
// Define the pins for the LM35 temperature sensor
const int lm35_pin = A0;
// Define the temperature threshold in Celsius
const float temp_threshold = 28.0;
Stepper myStepper(steps_per_revolution, motor_pin1, motor_pin3, motor_pin2, motor_pin4);
void setup() {
// Initialize the serial communication
Serial.begin(9600);
myStepper.setSpeed(10);
}
void loop() {
// Read the LM35 value
int lm35_value = analogRead(lm35_pin);
// Convert the LM35 value to temperature in Celsius
float voltage = lm35_value * 5.0 / 1023.0;
float temperature = voltage * 100.0;
// Print the temperature value to the serial monitor
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
// If the temperature is above the threshold, turn on the stepper motor
if (temperature > temp_threshold) {
myStepper.step(steps_per_revolution);
}
delay(1000);
}