Amaldi Robot Finale rev 2.0

Dependencies:   mbed X-NUCLEO-IHM05A1

Files at this revision

API Documentation at this revision

Comitter:
francesco01
Date:
Sat Nov 24 15:46:05 2018 +0000
Parent:
14:8e890b00c826
Commit message:
modifiche motorino

Changed in this revision

RobotFinale.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 8e890b00c826 -r d7126015fe69 RobotFinale.cpp
--- a/RobotFinale.cpp	Sat Nov 24 14:37:43 2018 +0000
+++ b/RobotFinale.cpp	Sat Nov 24 15:46:05 2018 +0000
@@ -101,7 +101,8 @@
 DigitalOut LedYAS (PC_8);
 DigitalOut LedRPD (PA_13);
 DigitalOut LedRPS (PA_14) ; 
-
+DigitalOut OutA (PB_0);
+DigitalOut OutB (PC_1);
 
 // Input/Output Digitali usati per interfaccia RPI
 DigitalIn InLightSwitchRPI (PB_9); // accende e spegne le Luci rosse e gialle = GPIO20
@@ -264,12 +265,49 @@
     CalculateSinewave(AMPLITUDE, (AMPLITUDE*fAmp), (PI/2.0)); // generazione della sinusoide con valori nominali
     //+++++++++++++ FINE Genera Sinusoide +++++++++++++++++++++
     
-    /*
+    
     while(true)
     {
-       
+     if(myButton==0)
+        {
+         //Ferma motore
+        OutA=0;
+        OutB=0;
+        pc.printf("OutA OutB = 00\r\n");
+        wait_ms(2000);
+        
+        
+        // Ruota Left
+        OutA=0;
+        OutB=1;
+        pc.printf("OutA OutB = 01\r\n");
+        wait_ms(2000);
+         //Ferma motore
+        OutA=0;
+        OutB=0;
+        pc.printf("OutA OutB = 00\r\n");
+        wait_ms(2000);
+        }
+        else 
+        {
+           //Ferma motore
+        OutA=1;
+        OutB=0;
+        pc.printf("OutA OutB = 10\r\n");
+        wait_ms(2000);
+        
+        // Ruota Right
+        OutA=1;
+        OutB=1;
+        pc.printf("OutA OutB = 11\r\n");
+        wait_ms(2000);
+        
+        OutA=1;
+        OutB=0;
+        pc.printf("OutA OutB = 10\r\n");
+        wait_ms(2000);   
     }
-    */
+    
     
     //++++ INIZIO Ciclo Principale ++++
     while (true) 
@@ -277,17 +315,42 @@
         //++++++++++++++ INIZIO Pilotaggio Motore su comando da Raspberry+++++++++++++
         if(InMotorSwitchRPI==1)
         {
-          // Request device to go position -3200 
-          motor->go_to(150);
-          // Waiting while the motor is active. 
-          motor->wait_while_active();
+         //Ferma motore
+        OutA=0;
+        OutB=0;
+        pc.printf("OutA OutB = 00\r\n");
+        wait_ms(2000);
+        
+        
+        // Ruota Left
+        OutA=0;
+        OutB=1;
+        pc.printf("OutA OutB = 01\r\n");
+        wait_ms(2000);
+         //Ferma motore
+        OutA=0;
+        OutB=0;
+        pc.printf("OutA OutB = 00\r\n");
+        wait_ms(2000);
         }
         else 
         {
-           // Request device to go position -3200 
-           motor->go_to(-150);
-           // Waiting while the motor is active. 
-           motor->wait_while_active();
+           //Ferma motore
+        OutA=1;
+        OutB=0;
+        pc.printf("OutA OutB = 10\r\n");
+        wait_ms(2000);
+        
+        // Ruota Right
+        OutA=1;
+        OutB=1;
+        pc.printf("OutA OutB = 11\r\n");
+        wait_ms(2000);
+        
+        OutA=1;
+        OutB=0;
+        pc.printf("OutA OutB = 10\r\n");
+        wait_ms(2000);
         }
         //++++++++++++++ FINE Pilotaggio Motore +++++++++++++
         //++++++++++++++ INIZIO Accensione LED da comando Raspberry +++++++
@@ -454,4 +517,4 @@
     }
     //++++ FINE Ciclo Principale ++++
 }
-
+}
\ No newline at end of file