![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
temp
Fork of LM35 by
main.cpp@0:aed747a24dcd, 2013-05-08 (annotated)
- Committer:
- GRG
- Date:
- Wed May 08 08:57:08 2013 +0000
- Revision:
- 0:aed747a24dcd
- Child:
- 1:eb9898cde584
LM35 with LCD
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GRG | 0:aed747a24dcd | 1 | #include "mbed.h" |
GRG | 0:aed747a24dcd | 2 | #include "TextLCD.h" |
GRG | 0:aed747a24dcd | 3 | |
GRG | 0:aed747a24dcd | 4 | AnalogIn LM35(p15); |
GRG | 0:aed747a24dcd | 5 | |
GRG | 0:aed747a24dcd | 6 | TextLCD lcd(p21,p22,p23,p24,p25,p26); |
GRG | 0:aed747a24dcd | 7 | |
GRG | 0:aed747a24dcd | 8 | int main() |
GRG | 0:aed747a24dcd | 9 | { |
GRG | 0:aed747a24dcd | 10 | float tempC,tempF,a[10],avg; |
GRG | 0:aed747a24dcd | 11 | int i; |
GRG | 0:aed747a24dcd | 12 | |
GRG | 0:aed747a24dcd | 13 | while(1) |
GRG | 0:aed747a24dcd | 14 | { |
GRG | 0:aed747a24dcd | 15 | |
GRG | 0:aed747a24dcd | 16 | avg=0; |
GRG | 0:aed747a24dcd | 17 | for(i=0;i<10;i++) |
GRG | 0:aed747a24dcd | 18 | { |
GRG | 0:aed747a24dcd | 19 | a[i]=LM35.read(); |
GRG | 0:aed747a24dcd | 20 | wait(.02); |
GRG | 0:aed747a24dcd | 21 | } |
GRG | 0:aed747a24dcd | 22 | for(i=0;i<10;i++) |
GRG | 0:aed747a24dcd | 23 | { |
GRG | 0:aed747a24dcd | 24 | avg=avg+(a[i]/10); |
GRG | 0:aed747a24dcd | 25 | } |
GRG | 0:aed747a24dcd | 26 | |
GRG | 0:aed747a24dcd | 27 | |
GRG | 0:aed747a24dcd | 28 | tempC=(avg*3.685503686*100); |
GRG | 0:aed747a24dcd | 29 | tempF=(9.0*tempC)/5.0 + 32.0; |
GRG | 0:aed747a24dcd | 30 | lcd.locate(0,0); |
GRG | 0:aed747a24dcd | 31 | lcd.printf(" Temperature "); |
GRG | 0:aed747a24dcd | 32 | lcd.locate(0,1); |
GRG | 0:aed747a24dcd | 33 | lcd.printf("%.2f C %.2f F",tempC,tempF); |
GRG | 0:aed747a24dcd | 34 | |
GRG | 0:aed747a24dcd | 35 | wait(.5); |
GRG | 0:aed747a24dcd | 36 | } |
GRG | 0:aed747a24dcd | 37 | } |