Hello,
I am controlling a radio controlled car with arduino and processing. I am using an Logitech Dual action controller as an input device, and that device has an x/y values. I want to send one key with port.write when the x is 0 and another one when it is on max. No pwm controll on the car.
How can I do this? I am using procontroll library in processing. Right now I am sending data trough a cable, since my radio module died..
My code so far:
I am controlling a radio controlled car with arduino and processing. I am using an Logitech Dual action controller as an input device, and that device has an x/y values. I want to send one key with port.write when the x is 0 and another one when it is on max. No pwm controll on the car.
How can I do this? I am using procontroll library in processing. Right now I am sending data trough a cable, since my radio module died..
My code so far:
- import processing.serial.*;
import procontroll.*;
ControllIO controllIO;
ControllDevice joypad;
Serial port;
String portname = "COM3";
int baudrate = 19200;
void setup() {
port = new Serial(this, portname, baudrate);
controllIO = ControllIO.getInstance(this);
joypad = controllIO.getDevice("Logitech Dual Action");
joypad.plug(this, "forward", ControllIO.ON_PRESS, 8);
joypad.plug(this, "stop_forward", ControllIO.ON_RELEASE, 8);
joypad.plug(this, "backwards", ControllIO.ON_PRESS, 7);
joypad.plug(this, "stop_backwards", ControllIO.ON_RELEASE, 7);
}
void forward() {
port.write('w');
}
void stop_forward() {
port.write('q');
}
void backwards() {
port.write('s');
}
void stop_backwards() {
port.write('e');
}
void draw() {
}
1