/*
Simule une NTC@50k (Thermo Resistance de 50Ohm)
created on 8 Nov 2022
by Eddy MERCIER
*/
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
long resistance;
void setup() {
Serial.begin(9600);
}
void loop() {
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
//val = map(val, 0, 1023, -55, 150); // scale it to use it with the servo (value between 0 and 180)
// resistance = map(val, 0, 1023, 15019, 309) *10; // 0°C = 150.190 Ohm & 100°C = 3.090 Ohm
resistance = simulNTC(val);
Serial.print(resistance);
Serial.println(" Ohm");
delay(100); // waits for the servo to get there
}
long simulNTC(int val) {
return map(val, 0, 1023, 15019, 309) *10; // 0°C = 150.190 Ohm & 100°C = 3.090 Ohm
}