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-rtos mbed PinDetect
Fork of FinalMotorControl by
Revision 3:15be78948724, committed 2016-04-08
- Comitter:
- mjhaugsdal
- Date:
- Fri Apr 08 13:27:08 2016 +0000
- Parent:
- 2:25bcc26f7a5b
- Child:
- 4:4d655fdae399
- Commit message:
- Program for controlling stepper motors with threads.; Thanks to rlanghbv
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Apr 07 11:05:26 2016 +0000
+++ b/main.cpp Fri Apr 08 13:27:08 2016 +0000
@@ -9,10 +9,8 @@
DigitalOut IN3(D5);
DigitalOut IN4(D6);
-Mutex stdio_mutex;
static int fart = 1000;
-static char global_direction;
-static int global_counter;
+static char m_cmd = 'x';
void step4Right()
@@ -70,10 +68,11 @@
{
while(true)
{
- //scanf(" %c", &global_direction);
- //global_direction=getchar();
+
if(pc.readable())
- { global_direction=pc.getc(); }
+ { m_cmd=pc.getc();
+
+ }
Thread::wait(10);
}
@@ -83,26 +82,46 @@
{
//Thread 1 has constant feed from usb
Thread t1(input);
+ static char global_direction;
+ printf("Started");
+
while (true)
{
- step4Left();
-
- /*
- if (global_direction == '0')
+
+
+ if (m_cmd == '0')
+ {
+ global_direction = '0';
+ step4Left();
+ //printf("%c \n" + global_direction);
+ }
+ else if (m_cmd == '1')
+ {
+ global_direction = '1';
+ step4Right();
+ //printf("RIGHT \n");
+ }
+ if (m_cmd == 'a')
+ {
+ fart = 1000;
+
+ }
+ else if (m_cmd == 'b')
+ {
+ fart = 5000;
+ }
+ if (global_direction =='0')
{
step4Left();
- printf("%c \n" + global_direction);
- } */
- /*else if (global_direction == '1')
+ }
+ else if (global_direction == '1')
{
step4Right();
- //printf("RIGHT \n");
- } */
- /* else
+ }
+ else
{
- //Do nothing
-
- }*/
+ global_direction = 'x';
+ }
}
-} //END Main
\ No newline at end of file
+} //END Main
