Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int tmpPin = A5;
- void setup() {
- pinMode(tmpPin, INPUT);
- Serial.begin(9600);
- }
- void loop() {
- float celsius_avlest = readTMP();
- Serial.println(celsius_avlest);
- }
- float readTMP() {
- // Leser av TMP36: ADC-verdi
- float readValue = analogRead(tmpPin);
- // Regner om fra ADC-verdi til spenning
- float voltage = (readValue*5)/1024;
- // Regner om fra spenning til celsius
- float celsius = (voltage-0.5)*100;
- return celsius;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement