lm3531
LM35.cpp@0:b83c07e29cbb, 2016-12-03 (annotated)
- Committer:
- arturogasca
- Date:
- Sat Dec 03 11:43:42 2016 +0000
- Revision:
- 0:b83c07e29cbb
lm35
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
arturogasca | 0:b83c07e29cbb | 1 | #include "LM35.h" |
arturogasca | 0:b83c07e29cbb | 2 | |
arturogasca | 0:b83c07e29cbb | 3 | LM35::LM35(PinName pin) : |
arturogasca | 0:b83c07e29cbb | 4 | sensorPin(pin) |
arturogasca | 0:b83c07e29cbb | 5 | { |
arturogasca | 0:b83c07e29cbb | 6 | } |
arturogasca | 0:b83c07e29cbb | 7 | |
arturogasca | 0:b83c07e29cbb | 8 | LM35::~LM35() |
arturogasca | 0:b83c07e29cbb | 9 | { |
arturogasca | 0:b83c07e29cbb | 10 | } |
arturogasca | 0:b83c07e29cbb | 11 | |
arturogasca | 0:b83c07e29cbb | 12 | float LM35::get() |
arturogasca | 0:b83c07e29cbb | 13 | { |
arturogasca | 0:b83c07e29cbb | 14 | avg=0; |
arturogasca | 0:b83c07e29cbb | 15 | for(i=0;i<10;i++) |
arturogasca | 0:b83c07e29cbb | 16 | { |
arturogasca | 0:b83c07e29cbb | 17 | a[i]=sensorPin.read(); |
arturogasca | 0:b83c07e29cbb | 18 | wait(.02); |
arturogasca | 0:b83c07e29cbb | 19 | } |
arturogasca | 0:b83c07e29cbb | 20 | for(i=0;i<10;i++) |
arturogasca | 0:b83c07e29cbb | 21 | { |
arturogasca | 0:b83c07e29cbb | 22 | avg=avg+(a[i]/10); |
arturogasca | 0:b83c07e29cbb | 23 | } |
arturogasca | 0:b83c07e29cbb | 24 | |
arturogasca | 0:b83c07e29cbb | 25 | tempC=(avg*3.685503686*100); |
arturogasca | 0:b83c07e29cbb | 26 | |
arturogasca | 0:b83c07e29cbb | 27 | return (tempC); |
arturogasca | 0:b83c07e29cbb | 28 | } |
arturogasca | 0:b83c07e29cbb | 29 |