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.
Revision 0:08ced55ecd21, committed 2016-12-03
- Comitter:
- arturogasca
- Date:
- Sat Dec 03 04:25:15 2016 +0000
- Commit message:
- mljko
Changed in this revision
| LM35.cpp | Show annotated file Show diff for this revision Revisions of this file |
| LM35.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LM35.cpp Sat Dec 03 04:25:15 2016 +0000
@@ -0,0 +1,29 @@
+#include "LM35.h"
+
+LM35::LM35(PinName pin) :
+ sensorPin(pin)
+{
+}
+
+LM35::~LM35()
+{
+}
+
+float LM35::get()
+{
+ avg=0;
+ for(i=0;i<10;i++)
+ {
+ a[i]=sensorPin.read();
+ wait(.02);
+ }
+ for(i=0;i<10;i++)
+ {
+ avg=avg+(a[i]/10);
+ }
+
+ tempC=(avg*3.685503686*100);
+
+ return (tempC);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LM35.h Sat Dec 03 04:25:15 2016 +0000
@@ -0,0 +1,33 @@
+/* LM35.h */
+#ifndef LM35_H_
+#define LM35_H_
+
+#include "mbed.h"
+
+
+/**
+*/
+class LM35
+{
+public:
+ /** Constructor
+ */
+ LM35(PinName pin);
+
+ /** Destructor
+ */
+ ~LM35();
+
+ /** Get temperature
+ */
+ float get();
+
+private:
+
+ AnalogIn sensorPin;
+ float tempC,a[10],avg;
+ int i;
+
+};
+
+#endif /* LM35_H_ */
\ No newline at end of file