lab3_demo_thermistor.ino
587 Bytes
#define THERMISTOR_PIN A0
/* Arduino ADC on 10-bitine - st 2^10 = 1024 */
#define ADC_RESOLUTION 1024
/* Kasuta enda Arduino võrdluspinget */
#define REF_VOLTAGE 9.00
const uint16_t tickDelay = 500;
void setup()
{
Serial.begin(9600);
pinMode(THERMISTOR_PIN, INPUT);
}
void loop()
{
uint16_t tempSensor = analogRead(THERMISTOR_PIN);
float tempInC = ((tempSensor / (float)ADC_RESOLUTION) * REF_VOLTAGE - 0.5) * 100;
Serial.print("Temperatuur: ");
Serial.print(tempInC);
Serial.println("°C");
delay(tickDelay);
}