Last active
November 18, 2016 14:59
-
-
Save manashmandal/d8de9c0c092eea460649a4f962ca481f to your computer and use it in GitHub Desktop.
LM35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define BAUD 9600 | |
class LM35 { | |
private: | |
byte pin; | |
unsigned int reading; | |
public: | |
LM35(byte pin){ | |
pin = pin; | |
} | |
void begin(void){ | |
pinMode(pin, INPUT); | |
} | |
double getTemperature(void){ | |
reading = analogRead(pin); | |
return (reading / 9.31); | |
} | |
}; | |
//LM35 temp_sensor1(0); | |
LM35 temp_sensor2(1); | |
void setup(){ | |
analogReference(INTERNAL); | |
Serial.begin(BAUD); | |
//temp_sensor1.begin(); | |
temp_sensor2.begin(); | |
//Add as many as you want | |
} | |
void loop(){ | |
//Serial.println("First sensor: " + String(temp_sensor1.getTemperature()) + "\n"); | |
Serial.println("Second sensor: " + String(temp_sensor2.getTemperature()) + "\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment