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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 3:95a3a1fbc807
- Parent:
- 2:d42e168b0fa7
- Child:
- 4:97d107efa17e
--- a/main.cpp Thu Jun 25 17:44:28 2020 +0000
+++ b/main.cpp Thu Jun 25 17:52:14 2020 +0000
@@ -25,6 +25,8 @@
long speed;
long adc;
+bool start = 0;
+
int main()
{
pc.baud(115200);
@@ -33,10 +35,29 @@
while(1)
{
- adc = pot.read() * 4096;
- speed =_scale.from(adc);
- //pc.printf("%i\r",speed);
- motor.one_step(1, speed, &prevStep);
+ if((sw == 0) && (start == 0))
+ {
+ start = 1;
+ wait(1);
+ }
+
+ if((sw == 0) && (start == 1))
+ {
+ start = 0;
+ wait(1);
+ }
+
+ if(start == 1)
+ {
+ adc = pot.read() * 4096;
+ speed =_scale.from(adc);
+ //pc.printf("%i\r",speed);
+ motor.one_step(1, speed, &prevStep);
+ }
+ else
+ {
+ motor.stop();
+ }
}
}