Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 4:8249fab4d8d3
- Parent:
- 1:3ca91ad8e927
- Child:
- 5:756dc04a891c
--- 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&µswitch2==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);
+ }
+*/