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
- Committer:
- mbed_Cookbook_SE
- Date:
- 2016-01-20
- Revision:
- 3:7bc0db64fa61
- Parent:
- 2:78ba5d3f0ac9
File content as of revision 3:7bc0db64fa61:
#include "mbed.h"
#include "SB1602E.h"
#include "SDFileSystem.h"
#define LOG_MAX 120
AnalogIn sensor(dp13);
SB1602E lcd( dp5, dp27 );
SDFileSystem sd(dp2, dp1, dp6, dp4, "sd");
int main() {
int counter = 0;
int16_t TmpLog[LOG_MAX];
lcd.contrast(0x30);
while(1) {
float Temperature;
Temperature = (sensor * 3.3 - 0.6) / 0.01;
lcd.clear();
lcd.printf(0,0,"%.2f",Temperature);
if( counter < LOG_MAX )
{
TmpLog[counter] = (int16_t)(Temperature*100.0);
counter++;
}
else if( counter == LOG_MAX )
{
FILE *fp = fopen("/sd/TempLog.csv", "w");
for(int i=0;i<counter;i++)
{
fprintf(fp,"%d,%.2f\r\n",i,(float)TmpLog[i]/100.0);
}
fclose(fp);
lcd.printf(0,1,"RecEnd");
counter++;
}
else
{
lcd.printf(0,1,"RecEnd");
}
wait(60.0);
}
}