RoboticsGeneral

GoBLE app with Romeo ble mini v1.1

userHead kan.jimmy 2018-07-03 05:14:50 1960 Views1 Replies
Hi, try using GoBLE app to control the Romeo ble mini v1.1, the following code was uploaded to the Romeo mini fine and Bluetooth connected, but only the last button worked, the rest is not responding. Any ideas?
Thanks

#include <Metro.h>
#include "GoBLE.h"
#include <Romeo_m.h>

int joystickX, joystickY;
int buttonState[7];

void setup(){
Goble.begin();
Serial.begin(115200);
}

void loop() {
if(Goble.available()){
joystickX = Goble.readJoystickX();
joystickY = Goble.readJoystickY();

buttonState[SWITCH_UP] = Goble.readSwitchUp();
buttonState[SWITCH_DOWN] = Goble.readSwitchDown();
buttonState[SWITCH_LEFT] = Goble.readSwitchLeft();
buttonState[SWITCH_RIGHT] = Goble.readSwitchRight();
buttonState[SWITCH_SELECT] = Goble.readSwitchSelect();
buttonState[SWITCH_START] = Goble.readSwitchStart();

Serial.print("Joystick Value: ");
Serial.print(joystickX);
Serial.print(" ");
Serial.println(joystickY);

if (buttonState[1] == PRESSED) {
Romeo_m.motorControl(Forward,100,Forward,100);
}
if (buttonState[2] == PRESSED) {
Romeo_m.motorControl(Reverse,100,Forward,100);
}
if (buttonState[3] == PRESSED) {
Romeo_m.motorControl(Forward,100,Reverse,100);
}
if (buttonState[4] == PRESSED) {
Romeo_m.motorControl(Reverse,100,Reverse,100);
}

if (buttonState[1] == RELEASED || buttonState[2] == RELEASED || buttonState[2] == RELEASED || buttonState[4] == RELEASED) //Serial.println("Released!");
{
Romeo_m.motorStop();
}
}
}
2018-07-04 00:59:22 Never mind, got it working after fixing the code logic. userHeadPic kan.jimmy