pressure_masuda

Dependencies:   SCP1000 SCP1000_Example TextLCD mbed

Fork of SCP1000_Example by Kenneth Adams

Revision:
2:479b749065ee
Parent:
1:6fb7e6fcbb68
--- a/main.cpp	Wed Oct 20 17:51:36 2010 +0000
+++ b/main.cpp	Tue Mar 12 07:54:43 2013 +0000
@@ -1,10 +1,192 @@
-#include "mbed.h"
-#include "SCP1000.h"
-
-Serial pc(USBTX, USBRX);
-SCP1000 scp1000(p5,p6,p7,p8);
-
-int main() {
-    pc.printf("The pressure is %d Pa and the temperature is %f C", scp1000.readPressure(), scp1000.readTemperature());
-    return(0);
-}
\ No newline at end of file
+#include "mbed.h"
+#include "SCP1000.h"
+#include "TextLCD.h"
+
+//TextLCD lcd(p24, p26, p27, p28, p29, p30); // rs, e, d0-d3
+
+DigitalOut myled(LED1);
+ADXL345 adx1345(p5,p6,p7,p9);
+SDFileSystem sd(p5,p6,p7,p10),"sd");
+I2C i2c(p28,p27);
+LocalFileSystem local("local");
+Serial pc(USBTX,USBFC);
+
+
+SCP1000 scp1000(p5,p6,p7,p8);
+
+PwmOut pwm(p21);
+
+Ticker timer;
+
+InterruptIn flight(p11);
+
+void start1();
+
+
+main()
+{
+       while(true)
+       {
+            flight.fall(&start1);
+            //data collect
+       }
+}
+
+/*void data()
+{
+      while(true){
+      lcd.cls();
+        lcd.printf("data collecting...");
+        }
+}
+*/
+/*void open()
+{
+timer.attach(&data,1.0);
+int start=500, end=2200;
+    while(true){
+        lcd.cls();
+        lcd.printf("open!!");
+        for(int p = start; p < end; p += 20) {
+            pwm.pulsewidth_us(p);
+            wait_ms(20);
+        }
+        for(int p = end; p >=start; p -= 20) {
+             pwm.pulsewidth_us(p);
+            wait_ms(20);
+        }
+    }
+        
+}
+*/
+
+
+/*void start()
+{
+      wait(0.1);
+      flight.fall(&start);
+      flight.rise(&start);
+      lcd.cls();
+      lcd.printf("2");
+}*/
+void start1(){
+
+       //timer.attach(&open,15);
+       int t=0;
+       int go=0;
+       
+       pwm.period_ms(20);
+         wait_ms(100);
+      flight.fall(&start1);
+      flight.rise(&start1);
+         double p0;
+         p0=scp1000.readPressure();
+        //lcd.cls();
+       // lcd.printf("start:%f", p0);
+        
+        while(t<8)
+        {
+        t++;
+        
+        double p1,p2,p3;
+        int t[3];
+        int i=0;
+        while(i<3)
+        {
+        p1=scp1000.readPressure();
+       // lcd.cls();
+       // lcd.printf("Pressure1:%f", p1);
+        wait(0.15);
+        p2= scp1000.readPressure();
+        lcd.cls();
+        lcd.printf("Pressure2:%f", p2);
+        wait(0.15);
+        p3=scp1000.readPressure();
+        lcd.cls();
+        lcd.printf("Pressure3:%f", p3);
+        wait(0.15);
+        t[i]=(p1+p2+p3)/3;
+        lcd.cls();
+        lcd.printf("Pressure:%f", t[i]);
+        i++;
+        
+        }
+               
+        if(t[0]<t[1])
+        {
+        if(t[1]<t[2])
+        {
+        
+        lcd.cls();
+        lcd.printf("open!!!");
+        int start=2000, end=3500;
+        for(int a=0;a<2;a++)
+        {
+        for(int p = start; p < end; p += 20) {
+            pwm.pulsewidth_us(p);
+            wait_ms(20);
+            
+        }
+        lcd.cls();
+        lcd.printf("A");
+        for(int p = end; p >=start; p -= 20) {
+             pwm.pulsewidth_us(p);
+            wait_ms(20);
+        }
+        lcd.cls();
+        lcd.printf("B");
+        }
+        go=1;
+        }else{
+        lcd.cls();
+        lcd.printf("rising2..%d,%d,%d",t[0],t[1],t[2]);
+        wait(0.4);
+        }
+        }else{
+        lcd.cls();
+        lcd.printf("rising1..%d,%d,%d",t[0],t[1],t[2]);
+        wait(0.4);
+        }   
+          
+        if(go==1)
+        {
+             
+             while(true)
+             {
+                     //data collecting
+              }
+        }
+       
+        }
+        int start=2000, end=3500;
+        //timer.attach(&data,5.0);
+        for(int b=0;b<2;b++)
+        {
+        lcd.cls();
+        lcd.printf("open!!");
+        for(int p = start; p < end; p += 20) {
+            pwm.pulsewidth_us(p);
+            wait_ms(20);
+        }
+        lcd.cls();
+        lcd.printf("A");
+        for(int p = end; p >=start; p -= 20) {
+             pwm.pulsewidth_us(p);
+            wait_ms(20);
+        }
+        lcd.cls();
+        lcd.printf("B");
+        
+    }
+    lcd.cls();
+    while(true){
+   
+                 //data collect
+               }
+   
+}
+
+
+
+
+