valve measurement board

Dependencies:   mbed ads1115_test SDFileSystem

Branch:
PressureResponse
Revision:
1:655abe8ab309
Parent:
0:cb9da8306a40
Child:
2:824e174ef9ea
--- a/main.cpp	Sun Oct 18 13:51:47 2020 +0000
+++ b/main.cpp	Tue Feb 23 02:13:21 2021 +0900
@@ -1,4 +1,6 @@
 #include "mbed.h"
+#include "SoftSerial.h"
+
 #include "SDFileSystem.h"
 
 #include "Adafruit_ADS1015.h"
@@ -9,6 +11,8 @@
 
 //Serial pc(USBTX, USBRX, 115200);
 
+SoftSerial valve_controler(p18,p19);//tx,rx
+
 I2C i2c(p9, p10);
 
 Adafruit_ADS1115 ads1115(&i2c, ADS1115_ADDR);
@@ -35,6 +39,8 @@
 int main()
 {
     timer.start();
+    valve_controler.baud(9600);
+
     uint16_t data[2];
     ads1115.setGain(GAIN_TWOTHIRDS);
     TempK.format(16, 0);
@@ -56,6 +62,7 @@
     fp = fopen(file_name, "w");
     sd_timer.start();
 
+    int dt = 0;
     while(1) {
 
         press_bit1 = ads1115.readADC_SingleEnded(1);
@@ -76,7 +83,12 @@
         temp2 = (float)((int16_t)data[0]) * TEMP_LSB;
 
         //pc.printf("%d\t%d\t%d\t%f\t%f\r\n", timer.read_ms(), press_bit1, press_bit2, temp1, temp2);
-        fprintf(fp, "%d\t%d\t%d\t%f\t%f\r\n", timer.read_ms(), press_bit1, press_bit2, temp1, temp2);
+	int time = timer.read_ms();
+	if(time - dt >= 100){
+		valve_controler.printf("%d",press_bit1);
+		dt = time;
+	}
+        fprintf(fp, "%d\t%d\t%d\t%f\t%f\r\n", time, press_bit1, press_bit2, temp1, temp2);
 
         if(sd_timer.read_ms() > 20*1000) {
             if(fp) {
@@ -85,4 +97,4 @@
             }
         }
     }
-}
\ No newline at end of file
+}