TEMPERATURE GAUGE

Temp gauge with adj

The code can be downloaded at:

https://github.com/triantara/ARDUINO-TRIANTARA/blob/main/Thermometer.zip

#include <AccelStepper.h>
#define HALFSTEP 8
// Motor pin definitions
#define motorPin1 12 // IN1 on the ULN2003 driver 1
#define motorPin2 11 // IN2 on the ULN2003 driver 1
#define motorPin3 10 // IN3 on the ULN2003 driver 1
#define motorPin4 9 // IN4 on the ULN2003 driver 1
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is conntec to the Arduino digital pin 2
#define ONE_WIRE_BUS 2
#define home_switch 4
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
// Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48
AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
void setup() {
Serial.begin(9600);
pinMode(home_switch, INPUT_PULLUP);
sensors.begin();
stepper1.setMaxSpeed(1000);
stepper1.setAcceleration(10000);
stepper1.setSpeed(100);

/* for make zero: restart arduino, let nedle go to 50 than press the button and hold, keep button press and reset the arduino,
after restart completed release the butron.
*/
while (digitalRead(home_switch)) { // Do this until the switch is activated
stepper1.runSpeed();
}

while (!digitalRead(home_switch)) { // Do this until the switch is not activated
stepper1.stop();
}
}//–(end setup )—

void loop() {
sensors.requestTemperatures();
float t= sensors.getTempCByIndex(0);
float angle=(t)*81.84; //4096/50
stepper1.runToNewPosition(angle);
Serial.println(t);

}