How to rotate a stepper motor as a function of temperature.

Hey guy,

I am working on a project where I have to build and program a controller unit using a thermistor by controlling the function of the stepper motor according to a specific sensed temperature.

I know I have to use an if statement, but I don’t know how to use it.

Would appreciate any help

Regards

int ThermistorPin = 0;
int Vo;
float R1 = 10000.0;
float logR2, R2, T, Tc, Tf;
float A = 0.00335401643468053;
float B = 0.000256523550896126;
float C = 2.60597012072052e-06;
float D = 6.32926126487455e-08;

void setup() {
Serial.begin(9600);
}

void loop() {
Vo = analogRead(ThermistorPin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R1/R2);
T = (1.0 / (A + BlogR2 + ClogR2logR2 + DlogR2logR2logR2));
Tc = T - 273.15;

Serial.print(“Temperature: “);
Serial.print(Tc);
Serial.println(” C”);
Serial.print("Vo: ");
Serial.println(Vo);
delay(500);
}

#include <Stepper.h>

const int stepsPerRevolution = 2048; // change this to fit the number of steps per revolution
const int RevolutionsPerMinute = 15; // Adjustable range of 28BYJ-48 stepper is 0~17 rpm

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);

void setup() {
myStepper.setSpeed(RevolutionsPerMinute);
// initialize the serial port:
Serial.begin(9600);
}

void loop() {
// step one revolution in one direction:
Serial.println(“clockwise”);
myStepper.step(stepsPerRevolution);
delay(500);

// step one revolution in the other direction:
Serial.println(“counterclockwise”);
myStepper.step(-stepsPerRevolution);
delay(500);
}

int ThermistorPin = 0;

Pin 0 is reserved for serial comms, and it has no analog input capability. Did you mean, 'A0'?

You can not have two setup() and two loop() functions in the same sketch.

What do you want the stepper to do, and at what temperatures?

Note: analogRead(0) does work, and reads analog pin A0. Very poor decision by the Arduino designers.