Create thermistor-1.ino
First test program (was embedded)
This commit is contained in:
parent
671ac247da
commit
0551911665
1 changed files with 30 additions and 0 deletions
30
Themistor/thermistor-1.ino
Normal file
30
Themistor/thermistor-1.ino
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// thermistor-1.ino Simple test program for a thermistor for Adafruit Learning System
|
||||
// https://learn.adafruit.com/thermistor/using-a-thermistor by Limor Fried, Adafruit Industries
|
||||
// MIT License - please keep attribution and consider buying parts from Adafruit
|
||||
|
||||
// the value of the 'other' resistor
|
||||
#define SERIESRESISTOR 10000
|
||||
|
||||
// What pin to connect the sensor to
|
||||
#define THERMISTORPIN A0
|
||||
|
||||
void setup(void) {
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
float reading;
|
||||
|
||||
reading = analogRead(THERMISTORPIN);
|
||||
|
||||
Serial.print("Analog reading ");
|
||||
Serial.println(reading);
|
||||
|
||||
// convert the value to resistance
|
||||
reading = (1023 / reading) - 1; // (1023/ADC - 1)
|
||||
reading = SERIESRESISTOR / reading; // 10K / (1023/ADC - 1)
|
||||
Serial.print("Thermistor resistance ");
|
||||
Serial.println(reading);
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
Loading…
Reference in a new issue