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
Diff: main.cpp
- Revision:
- 1:00fe5bf692b4
- Parent:
- 0:d034cdad5b6d
diff -r d034cdad5b6d -r 00fe5bf692b4 main.cpp
--- a/main.cpp Thu May 30 08:26:56 2019 +0000
+++ b/main.cpp Sat Jun 06 17:00:06 2020 +0000
@@ -1,28 +1,39 @@
#include "mbed.h"
-#include <SoftSerial.h>
-Serial ble(A4,A5);
-AnalogIn flowIn(A2);
+Serial ttl(PC_12,PD_2);
+AnalogIn flowIn(PA_1);
float flowVal1;
float flowVal2;
float Pressure;
+
float finalflow;
-
-float flow()
-{
+float flow(){
flowVal1=3.3*flowIn; //Logic level 3.3
flowVal2 = 1.5*flowVal1; //5v
Pressure =(125*flowVal2)-62.5;
- finalflow=(0.1989*sqrt(Pressure))+0.0284; //flow in litter per min
- return finalflow;
-
+ //finalflow=(0.3425*sqrt(Pressure))-0.198; //flow in litter per min
+ //finalflow= (-6.12e-5)*(Pressure)*(Pressure) + (2.98e-2)*Pressure - 8.83e-2;
+ return Pressure;
}
int main(){
-ble.baud(9600);
+ttl.baud(115200);
+
+ ttl.printf("$");//enter command mode only for rn
+ wait(0.1);
+ ttl.printf("$$");//enter command mode
+ wait(0.5);
+ ttl.printf("SN,Flow Calibration\r");//set new name
+ wait(0.5);
+ ttl.printf("SS,C0\r");//set transparent uart
+ wait(0.5);
+ ttl.printf("---\r");//enter data mode
+ wait(0.5);
+
while(1){
- ble.printf("E2.7, %f, 3.3\n", flow());
+ ttl.printf("%f\n", flow());
+ wait(0.1);
}
}