Prototipo

Dependencies:   freetronicsLCDShield mbed

Revision:
1:5372d7ce92ff
Parent:
0:c7f387fc3773
Child:
2:196bf6ff7eff
--- a/main.cpp	Tue May 27 22:12:23 2014 +0000
+++ b/main.cpp	Wed May 28 18:35:42 2014 +0000
@@ -10,22 +10,153 @@
 DigitalIn switch2(PTB9);
 DigitalIn switch3(PTB10);
 DigitalIn switch4(PTB11);
+DigitalIn start(PTE2);
 AnalogIn pot1(PTB0);
 AnalogIn pot2(PTB1);
 AnalogIn pot3(PTB2);
 AnalogIn pot4(PTB3);
-Timer t;
+Timer t1;
+Timer t2;
+Timer t3;
+Timer t4;
 
-float tiempo;
- 
+float tiempo1, tiempo2, tiempo3, tiempo4;
+int bandera, bandera1, bandera2, bandera3, bandera4;
+
+float pot11; 
+float pot22;
+float pot33;
+float pot44;
+
+
 int main() {
-   while(1){
-       if(PTB8==1){
-           
-           }
-       }
-   
-    /*lcd.printf("prototipo SR1");
+       
+       while(1){
+       
+       if(start==0){
+            bandera=1;
+            valvula1=0;
+            valvula2=0;
+            valvula3=0;
+            valvula4=0;
+            
+            lcd.setCursorPosition(0, 0);
+            if(switch1==1){
+                lcd.printf("ON ");
+                lcd.setCursorPosition(1, 0);
+                pot11=pot1.read();
+                lcd.printf("%0.1f",pot11);
+                
+                          }
+            else          {
+                lcd.printf("OFF");
+                lcd.setCursorPosition(1, 0);
+                lcd.printf("0.0 ");
+                
+                          }
+                          
+            lcd.setCursorPosition(0, 4);
+            if(switch2==1){
+                lcd.printf("ON ");
+                lcd.setCursorPosition(1, 4);
+                pot22=pot2.read();
+                lcd.printf("%0.1f",pot22);
+                          }
+            else          {
+                lcd.printf("OFF");
+                lcd.setCursorPosition(1, 4);
+                lcd.printf("0.0 ");
+                          }
+                       
+            lcd.setCursorPosition(0, 8);
+            if(switch3==1){
+                lcd.printf("ON ");
+                lcd.setCursorPosition(1, 8);
+                pot33=pot3.read();
+                lcd.printf("%0.1f",pot33);
+                          }
+            else          {
+                lcd.printf("OFF");
+                lcd.setCursorPosition(1, 8);
+                lcd.printf("0.0 ");
+                          } 
+                          
+            lcd.setCursorPosition(0, 12);
+            if(switch4==1){
+                lcd.printf("ON ");
+                lcd.setCursorPosition(1, 12);
+                pot44=pot4.read();
+                lcd.printf("%0.1f",pot44);
+                          }
+            else          {
+                lcd.printf("OFF");
+                lcd.setCursorPosition(1, 12);
+                lcd.printf("0.0 ");
+                          }  
+                          
+        }else{
+            if(bandera==1){
+            tiempo1=pot11*60;                   
+            tiempo2=pot22*60;
+            tiempo3=pot33*60;
+            tiempo4=pot44*60;
+            bandera1=switch1;
+            bandera2=switch2;
+            bandera3=switch3;
+            bandera4=switch4;
+            bandera=0;
+            }
+            if(bandera1==1){
+               bandera1=0;
+               valvula1=1;
+               t1.start();
+               }
+            if(t1>=tiempo1){
+               t1.stop();
+               t1.reset();
+               valvula1=0;
+               }
+            
+            if(bandera2==1){
+               bandera2=0;
+               valvula2=1;
+               t2.start();
+               }
+            if(t2>=tiempo2){
+               t2.stop();
+               t2.reset();
+               valvula2=0;
+               }
+             
+             if(bandera3==1){
+               bandera3=0;
+               valvula3=1;
+               t3.start();
+               }
+            if(t3>=tiempo3){
+               t3.stop();
+               t3.reset();
+               valvula3=0;
+               }
+               
+            if(bandera4==1){
+               bandera4=0;
+               valvula4=1;
+               t4.start();
+               }
+            if(t4>=tiempo4){
+               t4.stop();
+               t4.reset();
+               valvula4=0;
+               }           
+               
+               }                  
+        
+               }      
+            }
+
+
+ /*lcd.printf("prototipo SR1");
     wait(3);
     t.start();
     lcd.setCursorPosition(1, 0);
@@ -59,5 +190,4 @@
         }else if(t>=24){
             t.reset();    
         }        
-    }*/
-}
\ No newline at end of file
+    }*/
\ No newline at end of file