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: SB1602E SDFileSystem mbed
main.cpp@2:78ba5d3f0ac9, 2015-05-17 (annotated)
- Committer:
- mbed_Cookbook_SE
- Date:
- Sun May 17 06:31:47 2015 +0000
- Revision:
- 2:78ba5d3f0ac9
- Parent:
- 1:758a4ce77b97
- Child:
- 3:7bc0db64fa61
SD?????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_Cookbook_SE | 0:a84ca5aea16f | 1 | #include "mbed.h" |
mbed_Cookbook_SE | 1:758a4ce77b97 | 2 | #include "SB1602E.h" |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 3 | #include "SDFileSystem.h" |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 4 | |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 5 | #define LOG_MAX 120 |
mbed_Cookbook_SE | 0:a84ca5aea16f | 6 | |
mbed_Cookbook_SE | 0:a84ca5aea16f | 7 | AnalogIn sensor(dp13); |
mbed_Cookbook_SE | 1:758a4ce77b97 | 8 | SB1602E lcd( dp5, dp27 ); |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 9 | SDFileSystem sd(dp2, dp1, dp6, dp4, "sd"); |
mbed_Cookbook_SE | 0:a84ca5aea16f | 10 | |
mbed_Cookbook_SE | 0:a84ca5aea16f | 11 | int main() { |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 12 | int counter = 0; |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 13 | int16_t TmpLog[LOG_MAX]; |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 14 | |
mbed_Cookbook_SE | 1:758a4ce77b97 | 15 | lcd.contrast(0x30); |
mbed_Cookbook_SE | 0:a84ca5aea16f | 16 | while(1) { |
mbed_Cookbook_SE | 0:a84ca5aea16f | 17 | float Temperature; |
mbed_Cookbook_SE | 0:a84ca5aea16f | 18 | |
mbed_Cookbook_SE | 0:a84ca5aea16f | 19 | Temperature = (sensor * 3.3 - 0.6) / 0.01; |
mbed_Cookbook_SE | 0:a84ca5aea16f | 20 | |
mbed_Cookbook_SE | 1:758a4ce77b97 | 21 | lcd.clear(); |
mbed_Cookbook_SE | 1:758a4ce77b97 | 22 | lcd.printf(0,0,"%.2f",Temperature); |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 23 | |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 24 | if( counter < LOG_MAX ) |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 25 | { |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 26 | TmpLog[counter] = (int16_t)(Temperature*100.0); |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 27 | counter++; |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 28 | } |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 29 | else if( counter == LOG_MAX ) |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 30 | { |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 31 | FILE *fp = fopen("/sd/TempLog.csv", "w"); |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 32 | for(int i=0;i<counter;i++) |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 33 | { |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 34 | fprintf(fp,"%d,%.2f\r\n",i,(float)TmpLog[i]/100.0); |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 35 | } |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 36 | fclose(fp); |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 37 | lcd.printf(0,1,"RecEnd"); |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 38 | counter++; |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 39 | } |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 40 | else |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 41 | { |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 42 | lcd.printf(0,1,"RecEnd"); |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 43 | } |
mbed_Cookbook_SE | 2:78ba5d3f0ac9 | 44 | wait(60.0); |
mbed_Cookbook_SE | 0:a84ca5aea16f | 45 | } |
mbed_Cookbook_SE | 0:a84ca5aea16f | 46 | } |