control for robotic arm that can play chess using a granular gripper

Dependencies:   Encoder mbed HIDScope Servo MODSERIAL

Fork of chessRobot by a steenbeek

serialcom.cpp

Committer:
annesteenbeek
Date:
2015-10-29
Revision:
126:56866cefaa08
Parent:
125:749b8ce2e040
Child:
127:831f03471efb

File content as of revision 126:56866cefaa08:

#include "mbed.h"
#include "serialcom.h"
//#include "MODSERIAL.h"
#include "config.h"
#include "PID.h"
#include "buttons.h"
#include <string>

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");
    }
}