Motor control for robotic arm
Dependencies: MCP23017 WattBob_TextLCD mbed
Fork of Balanced Arm by
HandShake/HandShake.cpp
- Committer:
- wm70
- Date:
- 2016-01-29
- Revision:
- 9:87558e7cfecb
- Parent:
- 7:40d7d88deba3
- Child:
- 10:d7cce35b7bfd
File content as of revision 9:87558e7cfecb:
//********************************************************************* // Author: Adam Strutt // File: (PS2C.cpp) PlayStation 2 controller // Version: 1.0v // Date: 11/12/2015 //********************************************************************* #include <string> #include "HandShake.h" #include "mbed.h" #include "MCP23017.h" #include "WattBob_TextLCD.h" #include "AX12.h" MCP23017 *par_port1; WattBob_TextLCD *lcd1; //********************************************************************* // Object: PC_HandShake // Description: To create a HandShake object. //********************************************************************* PC_HandShake::PC_HandShake(Serial& PCbus, AX12& ax12) : _PCbus(PCbus), _ax12 (ax12){ //********************************************************************* // Description:Setting up the LCD display and turning on LCD display // Pins: p8, p10 //********************************************************************* par_port1 = new MCP23017(p9, p10, 0x40); par_port1->config(0x0F00, 0x0F00, 0x0F00); lcd1 = new WattBob_TextLCD(par_port1); par_port1->write_bit(1,BL_BIT); } //********************************************************************* // Method: PC_Connect // Description: This method is used to connect the PC to the mbed. //********************************************************************* void PC_HandShake::PC_Connect(void){ lcd1->cls(); lcd1->printf("Connecting"); lcd1->locate(1,0); lcd1->printf("to PC"); wait(2); lcd1->cls(); lcd1->printf("Waiting\n"); while('S' != _PCbus.getc()){ } while('S' != _PCbus.getc()){ } lcd1->cls(); lcd1->printf("Conneced\n"); wait(2); } void PC_HandShake::PC_Read(void){ lcd1->cls(); lcd1->printf("Reading"); lcd1->locate(1,0); lcd1->printf("to PC"); wait(2); lcd1->cls(); lcd1->printf("Waiting\n"); 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(); lcd1->printf("Reading\n"); wait(2); }