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.
Diff: pressure.h
- Revision:
- 2:bcf033cefa0e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pressure.h	Thu Jul 25 15:25:24 2019 +0000
@@ -0,0 +1,51 @@
+#include "mbed.h"
+
+AnalogIn flowadc(PC_4);
+
+float finalflow;
+float flowVal1;
+float flowVal2;
+float P1;
+int flag=0;
+int o=0;
+float bpArray[10];
+float fp;float sp;
+float FPressure;
+
+float pressure()
+{
+    while(1) {
+            wait(0.01);
+          flowVal1=3.3*flowadc; //Logic level 3.3
+          flowVal2 = 1.5*flowVal1; //5v
+          P1 =(125*flowVal2)-62.5;
+          if (flag==0){
+                    bpArray[o]=P1;  
+                    sp+=bpArray[o];
+                    o=o+1;
+                    if (o=9)
+                           {
+                               fp=sp/10;
+                               flag=1;
+                           }            
+                       }            
+          return P1;
+            }
+}
+
+float flow()
+{
+    while(1) {
+          if (flag ==0) 
+                {
+              finalflow=0;
+                }
+          if (flag ==1)
+                {
+          FPressure=pressure()-fp;
+          finalflow=(0.1989*sqrt(FPressure))+0.0284; //flow in litter per min
+          return finalflow;
+                }
+            }
+}
+