Motor control for robotic arm
Dependencies: MCP23017 WattBob_TextLCD mbed
Fork of Balanced Arm by
Diff: HandShake/HandShake.cpp
- Revision:
- 10:d7cce35b7bfd
- Parent:
- 9:87558e7cfecb
- Child:
- 11:7f74fb17c328
diff -r 87558e7cfecb -r d7cce35b7bfd HandShake/HandShake.cpp --- a/HandShake/HandShake.cpp Fri Jan 29 16:56:35 2016 +0000 +++ b/HandShake/HandShake.cpp Fri Jan 29 17:38:18 2016 +0000 @@ -49,9 +49,9 @@ wait(2); lcd1->cls(); lcd1->printf("Waiting\n"); - while('S' != _PCbus.getc()){ + while('s' != _PCbus.getc()){ } - while('S' != _PCbus.getc()){ + while('s' != _PCbus.getc()){ } lcd1->cls(); lcd1->printf("Conneced\n"); @@ -66,25 +66,50 @@ wait(2); lcd1->cls(); lcd1->printf("Waiting\n"); - while('s' != _PCbus.getc()){ - } - while(_PCbus.readable()==0){} - char _byteOne=_PCbus.getc(); + char Command[8]; + int x; while(_PCbus.readable()==0){} - char _byteTwo=_PCbus.getc(); + for(x=0;x<=8;x++) + { + Command[x] = _PCbus.getc(); + } + + if(Command[0]=='s') + { + if (Command[1]=='c') + if(Command[2]=='1') + _ax12.SetGoal(100); + + else if (Command[2]=='0') + _ax12.SetGoal(0); + + else return; + + } - if (_byteOne=='s'){ - }else if (_byteOne=='c'){ - switch(_byteTwo) - { - case '0': - _ax12.SetGoal(100); - break; - case '1': - _ax12.SetGoal(0); - break; - }} + //while('s' != _PCbus.getc()){ +// } +// while(_PCbus.readable()==0){} +// char _byteOne=_PCbus.getc(); +// +// while(_PCbus.readable()==0){} +// char _byteTwo=_PCbus.getc(); +// +// if (_byteOne=='s'){ +// } +// else if (_byteOne=='c') +// { +// switch(_byteTwo) +// { +// case '0': +// _ax12.SetGoal(100); +// break; +// case '1': +// _ax12.SetGoal(0); +// break; +// } +// } lcd1->cls();