ECE 2036 lab 7 IoT Clock starting template
Dependencies: 4DGL-uLCD-SE EthernetInterface NTPClient SDFileSystem mbed-rtos mbed wave_player
TMP36.h
00001 #include "mbed.h" 00002 00003 //Setup a new class for TMP36 sensor 00004 class TMP36 00005 { 00006 public: 00007 TMP36(PinName pin); 00008 TMP36(); 00009 operator float (); 00010 float read(); 00011 private: 00012 //class sets up the AnalogIn pin 00013 AnalogIn _pin; 00014 }; 00015 00016 TMP36::TMP36(PinName pin) : _pin(pin) 00017 { 00018 // _pin(pin) means pass pin to the AnalogIn constructor 00019 } 00020 00021 float TMP36::read() 00022 { 00023 //convert sensor reading to temperature in degrees C 00024 return ((_pin.read()*3.3)-0.500)*100.0; 00025 } 00026 //overload of float conversion (avoids needing to type .read() in equations) 00027 TMP36::operator float () 00028 { 00029 //convert sensor reading to temperature in degrees C 00030 return ((_pin.read()*3.3)-0.500)*100.0; 00031 }
Generated on Sun Aug 14 2022 16:31:58 by 1.7.2