I am able to make my Xbox 360 controller / Processing sketch work over USB cable on Arduino Uno without any issues on an RC CAR. Standard firmata loaded onto Uno and USB cable connecting to PC.
I am using the same code over blue tooth (HC-05) and Uno. I am able to connect to the UNO over bluetooth COM8 outgoing port. When I press the control buttons on the Controller, RC makes a very feeble sound and only able to move the steer left and right option ( very slow though), but no success in moving the car backward or forward. I am using standard Firmata on the Uno in both cases. If I remove the HC05 module from port # 0,1 on Arduino board and connect the USB cable directly from PC, the rc car works with out any issues. The code is based on tutorial from Processing's YouTube video.
Here is my code if any one gets a chance. I have made sure the baud rate of outgoing com8 port, Processing's , Firmata code's rate is set to 57600. HC05 baud rate configuration was done using SET command.
I am able to make my Xbox 360 controller / Processing sketch work over USB cable on Arduino Uno without any issues on an RC CAR. Standard firmata loaded onto Uno and USB cable connecting to PC. I am using the same code over blue tooth (HC-05) and Uno. I am able to connect to the UNO over bluetooth COM8 outgoing port. When I press the control buttons on the Controller, RC makes a very feeble sound and only able to move the steer left and right option ( very slow though), but no success in moving the car backward or forward. I am using standard Firmata on the Uno in both cases. If I remove the HC05 module from port # 0,1 on Arduino board and connect the USB cable directly from PC, the rc car works with out any issues. The code is based on tutorial from Processing's YouTube video.
Here is my code if any one gets a chance. I have made sure the baud rate of outgoing com8 port, Processing's , Firmata code's rate is set to 57600. HC05 baud rate configuration was done using SET command.
import net.java.games.input.; import org.gamecontrolplus.; import org.gamecontrolplus.gui.*;
import cc.arduino.; import g4p_controls.;
import org.firmata.*;
import processing.serial.*;
ControlDevice cd ; ControlIO cio; Arduino arduino; //boolean goF, goB, sL, sR; boolean goF=false; boolean goB=false; boolean sL=false; boolean sR=false; boolean sA=false;
int drFwd = 12; int drBkwd= 13; int strLeft = 7; int strRight= 8; int enblA = 3; int enblB = 6; String mode=null;
int COM_PORT = 0; int BAUD_RATE =57600;
int FWD_PWM_VALUE=180; int BKWD_PWM_VALUE=180; int STR_PWM_VALUE=180;
void setup() {
size(400,200);
cio = ControlIO.getInstance(this);
cd = cio.getMatchedDevice("rcPosv2");
if (cd == null ){ println("No COM PORT found"); System.exit (-1); } else { println(cd); }
arduino = new Arduino(this, Arduino.list()[COM_PORT],BAUD_RATE); arduino.pinMode(drFwd,Arduino.OUTPUT); arduino.pinMode(drBkwd,Arduino.OUTPUT); arduino.pinMode(strLeft,Arduino.OUTPUT); arduino.pinMode(strRight,Arduino.OUTPUT); arduino.pinMode(enblA,Arduino.OUTPUT); arduino.pinMode(enblB,Arduino.OUTPUT);
}
public void getUserInput() {
println(mode);
}
void draw() {
getUserInput(); printMode(mode); if(goF){ driveForward();
}else if (goB) {
driveBackWard();
}
if (sR){ steerRight(); } if (sL) { steerLeft(); }if (sA) { stopDrive(); }
}
void driveForward() { println("F" ); arduino.analogWrite(enblB, FWD_PWM_VALUE); arduino.digitalWrite(drFwd,Arduino.HIGH); arduino.digitalWrite(drBkwd,Arduino.LOW);
}
void driveBackWard() { println("B"); arduino.analogWrite(enblB, BKWD_PWM_VALUE); arduino.digitalWrite(drBkwd,Arduino.HIGH); arduino.digitalWrite(drFwd,Arduino.LOW);
}
void steerLeft(){ arduino.digitalWrite(strRight,Arduino.LOW); arduino.analogWrite(enblB, 0); arduino.analogWrite(enblA,STR_PWM_VALUE); arduino.digitalWrite(strLeft,Arduino.HIGH); println("in steering Left .......");
}
void steerRight(){ arduino.digitalWrite(strLeft,Arduino.LOW); arduino.analogWrite(enblB, 0); arduino.analogWrite(enblA, STR_PWM_VALUE); arduino.digitalWrite(strRight,Arduino.HIGH); println(" in steering Right ");
}
void stopDrive(){ arduino.analogWrite(enblB, 0); arduino.analogWrite(enblA, 0); arduino.digitalWrite(strLeft,Arduino.LOW); arduino.digitalWrite(strRight,Arduino.LOW); print("in the Stop All ");
}
void printMode(String mode){
println("mode is "+mode);
}