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: mbed ads1115_test SDFileSystem
Revision 12:8a4212e2642a, committed 2021-03-05
- Comitter:
- Yamasaki Taro
- Date:
- Fri Mar 05 02:01:41 2021 +0900
- Branch:
- PressureResponse
- Parent:
- 11:99a4552b4fa5
- Child:
- 13:19fb33032ebb
- Commit message:
- Changed communication protocol between control and measure
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Mar 05 00:32:59 2021 +0900
+++ b/main.cpp Fri Mar 05 02:01:41 2021 +0900
@@ -1,5 +1,4 @@
#include "mbed.h"
-#include "SoftSerial.h"
#include "SDFileSystem.h"
@@ -13,8 +12,6 @@
//
Serial wireless(p28,p27);
-SoftSerial valve_controler(p18,p19);//tx,rx
-
I2C i2c(p9, p10);
Adafruit_ADS1115 ads1115(&i2c, ADS1115_ADDR);
@@ -23,6 +20,11 @@
SPI TempK(p5, p6, p7);
+const int Threshold = 114514;//この値は適当。よく考えて決めること!!
+
+DigitalOut valve_controler1(p18);
+DigitalOut valve_controler2(p19);
+
DigitalOut led1(LED1);
DigitalOut ss1(p19);
@@ -42,7 +44,6 @@
{
timer.start();
wireless.baud(115200);
- valve_controler.baud(9600);
uint16_t data[2];
ads1115.setGain(GAIN_TWOTHIRDS);
@@ -102,12 +103,16 @@
wireless.printf("Tank Pressure is %d now.\r\n",press_bit1);
dt = time;
}
- if(valve_controler.readable() > 0 ){
- if((char)valve_controler.getc() == '?'){
- valve_controler.printf("%d",press_bit1);
- }
-
+ //valvcontroler---------------------
+ if(press_bit1 <= Threshold){
+ valve_controler1 = 0;
+ valve_controler2 = 0;
}
+ else{
+ valve_controler1 = 1;
+ valve_controler2 = 1;
+ }
+ //----------------------------------
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) {