Proyecto emprendetronika

Dependencies:   freetronicsLCDShield mbed

Fork of prototipo by Hector Tangarife

Files at this revision

API Documentation at this revision

Comitter:
davroina
Date:
Thu May 29 23:11:38 2014 +0000
Parent:
2:196bf6ff7eff
Commit message:
Proyecto con el algoritmo terminado para emprendetronika :D

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu May 29 20:59:21 2014 +0000
+++ b/main.cpp	Thu May 29 23:11:38 2014 +0000
@@ -11,17 +11,19 @@
 DigitalIn switch3(PTB10);
 DigitalIn switch4(PTB11);
 DigitalIn start(PTE2);
+DigitalIn paralelo(PTE3);
 AnalogIn pot1(PTB0);
 AnalogIn pot2(PTB1);
 AnalogIn pot3(PTB2);
 AnalogIn pot4(PTB3);
+Timer t;
 Timer t1;
 Timer t2;
 Timer t3;
 Timer t4;
 
 float tiempo1, tiempo2, tiempo3, tiempo4;
-int bandera, bandera1, bandera2, bandera3, bandera4;
+int bandera, bandera1, bandera2, bandera3, bandera4, banderaS;
 
 float pot11; 
 float pot22;
@@ -35,6 +37,7 @@
        
        if(start==0){
             bandera=1;
+            banderaS=1;
             valvula1=0;
             valvula2=0;
             valvula3=0;
@@ -104,6 +107,8 @@
             bandera4=switch4;
             bandera=0;
             }
+            if(paralelo==1){
+                
             if(bandera1==1){
                bandera1=0;
                valvula1=1;
@@ -148,6 +153,81 @@
                valvula4=0;
                }           
                
+            }else{
+                
+                //tiempo2=tiempo2+tiempo1;
+                //tiempo3=tiempo3+tiempo2;
+                //tiempo4=tiempo4+tiempo3;
+                if(banderaS==1){
+                    
+                if(switch1==1){
+                t1.start();
+                while(t1>=0 && t1<tiempo1){
+                    valvula1=1;
+                    valvula2=0;
+                    valvula3=0;
+                    valvula4=0;
+                    t2.start();
+                    t2.reset();
+                    
+                }
+                }
+                if(switch2==1){
+                t2.start();
+                while(t2>=0 && t2<tiempo2){
+                    valvula1=0;
+                    valvula2=1;
+                    valvula3=0;
+                    valvula4=0;
+                    t1.stop();
+                    t1.reset();
+                    t3.start();
+                    t3.reset();
+                }
+                }
+                if(switch3==1){
+                t3.start();    
+                while(t3>=0 && t3<tiempo3){
+                    valvula1=0;
+                    valvula2=0;
+                    valvula3=1;
+                    valvula4=0;
+                    t2.stop();
+                    t2.reset();
+                    t4.start();
+                    t4.reset();
+                }
+                }
+                if(switch4==1){
+                t4.start();            
+                while(t4>=0 && t4<tiempo4){
+                    valvula1=0;
+                    valvula2=0;
+                    valvula3=0;
+                    valvula4=1;
+                    t3.stop();
+                    t3.reset();
+                }                    
+                }
+                if(t4>tiempo4){
+                    t4.stop();
+                    //t2.stop();
+                    //t3.stop();
+                    //t4.stop();
+                    t4.reset();    
+                    //t2.reset();    
+                    //t3.reset();    
+                    //t4.reset();    
+                    valvula1=0;
+                    valvula2=0;
+                    valvula3=0;
+                    valvula4=0;
+                }      
+               
+               }
+               banderaS=0;
+               
+               }   
                }                  
         
                }