Tempareture sensor driver
Dependents: TMP36_Anlog_temperature_read Cayenne-X-NUCLEO-IDW01M1-TMP36 Cayenne-X-NUCLEO-IDW01M1-TMP36 Projektzlaczen ... more
Revision 0:ab3d7d0c34ce, committed 2013-02-12
- Comitter:
- zchen311
- Date:
- Tue Feb 12 06:23:02 2013 +0000
- Commit message:
- test2, has pb to change state, and mode setting. ; 1. adding cooling (done); 2. sensor log; 3.speaker; 4.pushbutton(done); 5. RGB
Changed in this revision
TMP36.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r ab3d7d0c34ce TMP36.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TMP36.h Tue Feb 12 06:23:02 2013 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" + +//Setup a new class for TMP36 sensor +class TMP36 +{ +public: + TMP36(PinName pin); + TMP36(); + operator float (); + float read(); +private: +//class sets up the AnalogIn pin + AnalogIn _pin; +}; + +TMP36::TMP36(PinName pin) : _pin(pin) +{ +// _pin(pin) means pass pin to the AnalogIn constructor +} + +float TMP36::read() +{ +//convert sensor reading to temperature in degrees C + return ((_pin.read()*3.3)-0.500)*100.0; +} +//overload of float conversion (avoids needing to type .read() in equations) +TMP36::operator float () +{ +//convert sensor reading to temperature in degrees C + return ((_pin.read()*3.3)-0.500)*100.0; +} + \ No newline at end of file