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_lcd LM75B mbed
main.cpp@0:229e08a49858, 2015-02-28 (annotated)
- Committer:
- ranafde
- Date:
- Sat Feb 28 04:41:34 2015 +0000
- Revision:
- 0:229e08a49858
3.5
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ranafde | 0:229e08a49858 | 1 | #include "mbed.h" |
| ranafde | 0:229e08a49858 | 2 | #include "LM75B.h" |
| ranafde | 0:229e08a49858 | 3 | #include "C12832_lcd.h" |
| ranafde | 0:229e08a49858 | 4 | #include <string> |
| ranafde | 0:229e08a49858 | 5 | |
| ranafde | 0:229e08a49858 | 6 | C12832_LCD lcd; |
| ranafde | 0:229e08a49858 | 7 | |
| ranafde | 0:229e08a49858 | 8 | LM75B sensor(p28,p27); |
| ranafde | 0:229e08a49858 | 9 | Serial pc(USBTX,USBRX); |
| ranafde | 0:229e08a49858 | 10 | |
| ranafde | 0:229e08a49858 | 11 | string s[2] = {"hi", "lo"}; |
| ranafde | 0:229e08a49858 | 12 | float prevTemp, curTemp; |
| ranafde | 0:229e08a49858 | 13 | string display; |
| ranafde | 0:229e08a49858 | 14 | int count = 1; |
| ranafde | 0:229e08a49858 | 15 | |
| ranafde | 0:229e08a49858 | 16 | int main () |
| ranafde | 0:229e08a49858 | 17 | { |
| ranafde | 0:229e08a49858 | 18 | prevTemp = sensor.read(); |
| ranafde | 0:229e08a49858 | 19 | curTemp = prevTemp; |
| ranafde | 0:229e08a49858 | 20 | display = s[1]; |
| ranafde | 0:229e08a49858 | 21 | while (1) { |
| ranafde | 0:229e08a49858 | 22 | curTemp = sensor.read(); |
| ranafde | 0:229e08a49858 | 23 | lcd.cls(); |
| ranafde | 0:229e08a49858 | 24 | lcd.locate(0,5); |
| ranafde | 0:229e08a49858 | 25 | lcd.printf("Temp = %.3f\n", sensor.read()); |
| ranafde | 0:229e08a49858 | 26 | lcd.locate(0,15); |
| ranafde | 0:229e08a49858 | 27 | if((curTemp - prevTemp) > 2 || (prevTemp - curTemp > 2)){ |
| ranafde | 0:229e08a49858 | 28 | count++; |
| ranafde | 0:229e08a49858 | 29 | display = s[count % 2]; |
| ranafde | 0:229e08a49858 | 30 | prevTemp = curTemp; |
| ranafde | 0:229e08a49858 | 31 | } |
| ranafde | 0:229e08a49858 | 32 | lcd.printf("%s",display); |
| ranafde | 0:229e08a49858 | 33 | wait(1.0); |
| ranafde | 0:229e08a49858 | 34 | } |
| ranafde | 0:229e08a49858 | 35 | |
| ranafde | 0:229e08a49858 | 36 | } |