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: C12832 LM75B mbed
Fork of app-board-LM75B by
main.cpp@6:4f08697d42cc, 2017-02-15 (annotated)
- Committer:
- Fleishmachine
- Date:
- Wed Feb 15 10:59:49 2017 +0000
- Revision:
- 6:4f08697d42cc
- Parent:
- 5:608f2bf4d3f7
demo
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Fleishmachine | 6:4f08697d42cc | 1 | |
| okano | 0:ce7a8546502b | 2 | #include "mbed.h" |
| chris | 5:608f2bf4d3f7 | 3 | #include "C12832.h" |
| Fleishmachine | 6:4f08697d42cc | 4 | |
| chris | 5:608f2bf4d3f7 | 5 | C12832 lcd(p5, p7, p6, p8, p11); |
| Fleishmachine | 6:4f08697d42cc | 6 | AnalogIn sensor(p15); |
| okano | 0:ce7a8546502b | 7 | |
| Fleishmachine | 6:4f08697d42cc | 8 | |
| Fleishmachine | 6:4f08697d42cc | 9 | float multiplier = 50; // this number got me closest to the reading on my multimeter temp probe |
| Fleishmachine | 6:4f08697d42cc | 10 | float temp; // calculated temperature |
| Fleishmachine | 6:4f08697d42cc | 11 | int count; // for computing average reading |
| Fleishmachine | 6:4f08697d42cc | 12 | float total; |
| Fleishmachine | 6:4f08697d42cc | 13 | float average; |
| Fleishmachine | 6:4f08697d42cc | 14 | int main() { |
| Fleishmachine | 6:4f08697d42cc | 15 | count = 0; |
| Fleishmachine | 6:4f08697d42cc | 16 | total = 0.0; |
| Fleishmachine | 6:4f08697d42cc | 17 | while (1) { |
| Fleishmachine | 6:4f08697d42cc | 18 | // formula is analog reading * multiplier |
| chris | 4:6df97cb10041 | 19 | |
| Fleishmachine | 6:4f08697d42cc | 20 | temp = sensor.read() * multiplier; |
| Fleishmachine | 6:4f08697d42cc | 21 | count++; |
| Fleishmachine | 6:4f08697d42cc | 22 | total += temp; |
| Fleishmachine | 6:4f08697d42cc | 23 | average = total / count; |
| Fleishmachine | 6:4f08697d42cc | 24 | |
| Fleishmachine | 6:4f08697d42cc | 25 | lcd.cls(); |
| Fleishmachine | 6:4f08697d42cc | 26 | lcd.locate(0,3); |
| Fleishmachine | 6:4f08697d42cc | 27 | lcd.printf("Temperature= %6.2f \n Average= %5.1f \n", temp , average ); |
| Fleishmachine | 6:4f08697d42cc | 28 | wait(1); |
| chris | 2:9e757151de9b | 29 | } |
| okano | 0:ce7a8546502b | 30 | } |
