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: LM19_Driver2 PDV_Driver2 SDFileSystem mbed
Diff: main.cpp
- Revision:
- 0:de819413de65
- Child:
- 1:477ec9bbee28
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Dec 01 23:58:15 2022 +0000
@@ -0,0 +1,102 @@
+#include "mbed.h"
+
+#include "SDFileSystem.h"
+
+#include "LM19_Driver.h"
+
+#include "PDV_Driver.h"
+
+
+Serial pc(USBTX, USBRX);
+SDFileSystem sd(p5, p6, p7, p8, "sd");
+LM19 t_sensor(p19);
+PDV photocell(p20);
+
+Timer print;
+
+Timer log_timer;
+
+
+
+int main()
+
+{
+
+ int t;
+
+ pc.printf("Start Log File\n");
+
+ mkdir("/sd/mydir", 0777);
+
+ FILE *fp = fopen("/sd/mydir/thm_ptc.txt", "w");
+
+
+
+ pc.printf("file_opened \n");
+
+
+ if(fp == NULL) {
+
+ error("Could not open file for write\n");
+
+ }
+
+ fprintf(fp,"Start Log File\n");
+
+ while(1) {
+
+ print.start();
+
+ log_timer.start();
+
+ if(log_timer.read()<31) {
+ if(print.read()>1) {
+
+ t=log_timer.read_ms();
+ pc.printf("$TEMP,1,2,%i,%.3f,%.3f;%\r\n",
+
+ t,
+
+ t_sensor.volt(),
+
+ t_sensor.temp());
+
+ fprintf(fp, "Time = %i, temperature=%f, voltage=%f\r\n",
+ t,
+
+ t_sensor.volt(),
+
+ t_sensor.temp());
+
+ pc.printf("$PDV,1,2,%i,%.3f,%.3f;%\r\n",
+
+ t,
+
+ photocell.volt(),
+
+ photocell.resistance());
+
+ fprintf(fp, "Time = %i, voltage=%f, resistance=%f\r\n",
+
+ t,
+
+ photocell.volt(),
+ photocell.resistance());
+
+ print.reset();
+ }
+
+ } else {
+ fprintf(fp, "Log File Full");
+
+ fclose(fp);
+
+ pc.printf("Log Successful\n");
+
+ wait(1);
+
+ }
+
+ }
+
+}
\ No newline at end of file
