lm3531
Revision 0:b83c07e29cbb, committed 2016-12-03
- Comitter:
- arturogasca
- Date:
- Sat Dec 03 11:43:42 2016 +0000
- Commit message:
- lm35
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 |
diff -r 000000000000 -r b83c07e29cbb LM35.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LM35.cpp Sat Dec 03 11:43:42 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); +} +
diff -r 000000000000 -r b83c07e29cbb LM35.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LM35.h Sat Dec 03 11:43:42 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