Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: 4DGL-uLCD-SE LSM9DS1_Library-KVS MBed_Adafruit-GPS-Library PinDetect X_NUCLEO_53L0A1 mbed-rtos mbed
Diff: TMP36.h
- Revision:
- 1:abc522e41d63
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TMP36.h Thu Dec 14 07:21:52 2017 +0000
@@ -0,0 +1,31 @@
+#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