![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
control for robotic arm that can play chess using a granular gripper
Dependencies: Encoder mbed HIDScope Servo MODSERIAL
Fork of chessRobot by
Diff: serialcom.cpp
- Revision:
- 126:56866cefaa08
- Parent:
- 125:749b8ce2e040
- Child:
- 127:831f03471efb
--- a/serialcom.cpp Thu Oct 29 17:41:10 2015 +0000 +++ b/serialcom.cpp Thu Oct 29 20:06:41 2015 +0000 @@ -1,24 +1,38 @@ #include "mbed.h" #include "serialcom.h" -#include "MODSERIAL.h" +//#include "MODSERIAL.h" #include "config.h" #include "PID.h" #include "buttons.h" #include <string> -MODSERIAL pc(USBTX, USBRX); +Serial pc(USBTX, USBRX); +DigitalOut pumpSwitch(pumpPin); char buf[128]; +void serialInit(){ + const int baudrate = 9600; + redLed.write(1); // dim the leds + blueLed.write(1); + greenLed.write(1); + + pc.baud(baudrate); + } + void serialCom(){ pc.scanf("%s", buf); if(strcmp(buf,"ledRed")==0){ redLed.write(!redLed.read()); + pc.printf("received data\n"); + pumpSwitch.write(!pumpSwitch.read()); } if(strcmp(buf,"ledBlue")==0){ blueLed.write(!blueLed.read()); + pc.printf("received data\n"); } if(strcmp(buf,"ledGreen")==0){ greenLed.write(!greenLed.read()); + pc.printf("received data\n"); } }