//Temperature sensor int ThermistorPin = A0; int Vo; int PWM=8; int Heater=3; float R1 = 100000; float logR2, R2, T, Tc, Tf; float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07; //MOTOR int x; #define BAUD (9600) void setup() { Serial.begin(9600); pinMode(Heater,OUTPUT); // HeaterOutput //MOTOR Serial.begin(BAUD); pinMode(6,OUTPUT); // Enable pinMode(7,OUTPUT); // Dir pinMode(5,OUTPUT); // Step digitalWrite(6,LOW); // Set Enable low } void loop() { Vo = analogRead(ThermistorPin); Serial.print("voltage: "); Serial.println(Vo); R2 = R1 * (1023.0 / (float)Vo - 1.0); logR2 = log(R2); T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2)); Tc = T - 273.15+54; Serial.print("Temperature:"); Serial.print(Tc); Serial.println(" C"); if (Tc < 250 && Tc>0) { analogWrite(Heater,PWM); } else if(Tc >= 250) { digitalWrite(Heater,LOW); } if (Tc>200) { digitalWrite(6,LOW); // Set Enable low digitalWrite(4,HIGH); // Set Dir high Serial.println("Loop 200 steps (1 rev)"); for(x = 0; x < 5; x++) // Loop 200 times { digitalWrite(5,HIGH); // Output high delayMicroseconds(10000); // Wait digitalWrite(5,LOW); // Output low delayMicroseconds(10000); // Wait } //Serial.println("Pause"); } //delay(500); // pause one second }