For 1st Year ROCO104

Dependencies:   mbed motor

Files at this revision

API Documentation at this revision

Comitter:
martinsimpson
Date:
Fri Feb 01 16:29:52 2019 +0000
Parent:
3:193629924f2d
Commit message:
Base template for ROCO104 first edition

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 193629924f2d -r 8249fab4d8d3 main.cpp
--- a/main.cpp	Thu Jan 17 17:02:17 2019 +0000
+++ b/main.cpp	Fri Feb 01 16:29:52 2019 +0000
@@ -42,7 +42,7 @@
 //
 int main ()
 {
-  pc.baud(115200);               //BAUD Rate to 115200
+  pc.baud(9600);               //BAUD Rate to 9600
   pc.printf("ROCO104 Demonstration Robot Buggy Plymouth University 2018/19\n\r");
 
   Wheel.Period_in_ms(TIME_PERIOD);//Set frequency of the PWMs
@@ -62,70 +62,36 @@
         wait(0.1);
         led=1; 
         wait(0.1);
-        //Test Microswitches with two different tones see tunes.cpp tunes.h
-        if(microswitch1==1)
-        {
-            pc.printf("Switch1 = %4.2fV\n\r",(float)microswitch1*3.3f);
-                            //printing value of microswitch1 in PuTTy window on PC
-                            //NB this is a Digital Input and so returns a Boolean 1 or 0
-                            //and so 'cast' the result into a 'float' type and multiply by 3.3!
-                            //to indicate voltage applied to pin.
-                            //see the instruction doc on how to install putty.
-            tone1();
-        }
-        if(microswitch2==1)
-        {
-            pc.printf("Switch 2 pressed\n\r");  //Another example of how to print a message telling about the program workings.
-            tone2();
-        }
+        //Test Microswitches with two different tones see tunes.cpp tunes.h or flash (led1 and led2) onboard LEDs
+ 
     }
   
     while(true)                             //Repeat the following forever NB always true!
     {
-        Wheel.Speed(duty,duty);             //Move Foward
-    
-        while(microswitch1==0&&microswitch2==0){wait(0.05);}// Loop here till a microswitch activates
-                                                            // NB short delay for debounce/noise(Electrical)
+// YOUR LINES OF CODE for your stratagy go between HERE! +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// Remember to use plenty of comments by using:-
+
+// Single line
 
-        Wheel.Stop();                       //STOP
-        wait(0.1);                          //Allow time for motors to stop
-      
-            if(microswitch1==1)             //Execute the following code if microswitch1 is activated
-            { 
-                Wheel.Stop();               //STOP
-                tone1();
-                Wheel.Speed(-duty,-duty);   //Move Back
-                wait(2.0f);
-                Wheel.Stop();               //STOP
-                wait(0.1f);
-                Wheel.Speed(-duty,duty);    //SPIN anti-clockwise
-                wait(0.75f);
-                Wheel.Stop();               //STOP
-                wait(0.1f);
-            }
+/*
+multiple
+lines
+*/
+
+
+
 
-            if(microswitch2==1)             //Execute the following code if microswitch2 is activated
-            {
-                Wheel.Stop();               //STOP
-                tone2();
-                Wheel.Speed(-duty,-duty);   //Move Back
-                wait(2.0f);
-                Wheel.Stop();               //STOP
-                wait(1.0f);
-                Wheel.Speed(duty,-duty);    //SPIN clockwise
-                wait(0.75f);
-                Wheel.Stop();               //STOP
-                wait(0.1f);
-            }
-    }// go back to start of while loop
-}
-//
-//----------------------------------------------------------------------------------------------
-//
-        //Consider these lines of code to Accelerate the motors
-//      for (float i=0.5f; i<=1.0f; i+=0.01f) //Accelerate  from 50% to 100%
-//      { 
-//        Wheel.Speed(i,i);
-//        wait(0.1f);
-//      }
+// and HERE! +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+    } // go back to start of while loop
+}  //end of int main()
+
+
 
+/*
+//Consider these lines of code to Accelerate the motors
+      for (float i=0.5f; i<=1.0f; i+=0.01f) //Accelerate  from 50% to 100%
+      { 
+        Wheel.Speed(i,i);
+        wait(0.1f);
+      }
+*/