PARCHEGGIO AMICO

Dependencies:   mbed Servo mbed-rtos beep hcsr04 TextLCD

Files at this revision

API Documentation at this revision

Comitter:
EnricoRuggieroB
Date:
Wed Apr 17 11:31:16 2019 +0000
Parent:
10:2fd7e922103f
Commit message:
FINITO

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Apr 09 09:56:34 2019 +0000
+++ b/main.cpp	Wed Apr 17 11:31:16 2019 +0000
@@ -15,7 +15,8 @@
 /******************************/
 //bluetooth
 Serial pc(USBTX, USBRX);             //istanza oggetto porta seriale
-Servo servo(D9);                     //istanza oggetto servomotore
+Servo servo(D9); 
+Servo uscita(D7);                    //istanza oggetto servomotore
 TextLCD lcd(D10,D11,D5,D4,D3,D2);    //istanza oggetto schermo
 /******************************/
 //sensori ad ultrasuoni
@@ -25,7 +26,7 @@
 HCSR04 sensor3(trigger3, echo3);
 HCSR04 sensor4(trigger4, echo4);
 /******************************/
-DigitalIn mybutton(D7);     //istanza oggetto bottone
+DigitalIn mybutton(PC_3);     //istanza oggetto bottone
 //Thread thread_sensori; // istanzia oggetto thread 
 
 bool occupata[5] = { false, false, false,false, false}; 
@@ -69,14 +70,14 @@
                         }                                        //se un parcheggio è libero conseguentemente non possono essere tutti occupati
                         while(1) 
                         {
-                            servo.write(angle);                      //non toccare 
+                            uscita.write(angle);                      //non toccare 
                             angle += 10;
                             if(angle > 90)
                             {
                                 wait(3);
                                 while(angle != 0 )
                                 {
-                                    servo.write(angle);
+                                    uscita.write(angle);
                                     angle -= 10;
                                     wait(0.25); 
                                 }
@@ -84,12 +85,8 @@
                             }
                             wait(0.25);
                         }
-              //if(occupata[1] == false && occupata[2] == false)    break;     // if(occupata[1]==true && occupata[2]==true) //sos = !sos;
-                }/*else if(sos==false && i==2){
-                    pc.printf("tutti i parcheggi sono occupati");
-                    break;
-                    }//else if(occupata[1]==true && occupata[2]==true) pc.printf("tutti i parcheggi sono occupati");
-           */
+             
+                }
             
            } while(1);   
            
@@ -97,14 +94,14 @@
               {
               while(1)
               {
-                            servo.write(angle);                      //non toccare 
+                            uscita.write(angle);                      //non toccare 
                             angle += 10;
                             if(angle > 90)
                             {
                                 wait(3);
                                 while(angle != 0 )
                                 {
-                                    servo.write(angle);
+                                    uscita.write(angle);
                                     angle -= 10;
                                     wait(0.25); 
                                 }
@@ -112,8 +109,7 @@
                             }
                             wait(0.25);
                 }     
-            }                                               // ciclo infinito, segnalera sempre i parcheggi liberi
-           //  if(occupata[1]==true && occupata[2]==true) pc.printf("tutti i parcheggi sono occupati");
+            }                                              
             if (sos == false)
                 {
                     pc.printf("parcheggio pieno");
@@ -122,12 +118,8 @@
     
 
                 }
-            /*else 
-            {
-                 lcd.printf("per riavviare premere l'apposito pulsante");
-                 pc.printf("per riavviare premere l'apposito pulsante");
-            }*/
-        }//if pulsante
+           
+        }
         
            
     }
@@ -158,8 +150,33 @@
         if(sensor3.get_dist_cm() <= 10.0)    occupata[3] = true;
         else    occupata[3] = false;
         
-        if(sensor4.get_dist_cm() <= 10.0)    occupata[4] = true;
-        else    occupata[4] = false; 
+        /*if(sensor4.get_dist_cm() <= 10.0)    occupata[4] = true;
+        else    occupata[4] = false;*/
+        
+        if(sensor4.get_dist_cm() <= 10.0)
+        {
+                int angle = 0;
+                while(1)
+                {
+                    servo.write(angle);                      //non toccare 
+                    angle += 10;
+                    if(angle > 90)
+                    {
+                        wait(3);
+                        while(angle != 0 )
+                        {
+                            servo.write(angle);
+                            angle -= 10;
+                            wait(0.25); 
+                        }
+                        
+                        if(angle == 0)     break;
+                    }
+                    wait(0.25);
+                }                                                  // ciclo infinito, segnalera sempre i parcheggi liberi
+         }
+        
+        
 }     
 
 int main()
@@ -173,3 +190,4 @@
         }
 }
     
+/**************L'HTML È UN LINGUAGGIO DI PROGRAMMAZIONE**************/
\ No newline at end of file