For all that is holy in the world --Watch the Video!!!
Here's what we got:
Processing inputs the posistion of the mouse (x,y). If the mouse is clicked, these cordinates are sent via serial (serial/USB) to a picaxe 28x1 inside of Walter's transmitter. I am using the regular sync cable and plug for this and the serrxd command. From here, the transmitter code is simply dealing with 2 variables, b1 and b2 which used to be coming from the x and y on the manual joystick and sends the same serial data (via RF) to Walter. One note about the Processing code, I chose a background size of 254 by 254 thus the mouse data was confined to 0-254 --the same as the range of the pots on the old joystick.
From here:
I need to do some cleaning up and refining of the code. When things are solid, I get to move on to building a real "virtual control panel" in processing and start adding more features. I am also looking at some Bluetooth moduals I can add to Walter. My new laptop has Bluetooth built in and with this modual, I can eliminate the need for the existing transmitter as a "middle man"... Anyone want to buy me a Bluetooth modual? :)
Code (Processing):
import processing.serial.*;
Serial myPort;
void setup() {
size(254, 254);
myPort = new Serial(this, "COM15", 4800);
}
void draw() {
if (mousePressed && (mouseButton == LEFT)) {
;
myPort.write (104);
delay (10);
myPort.write (mouseX);
delay (10);
myPort.write (mouseY);
delay (10);
}
line(0,0,254,254);
line(254,0,0,254);
}
Code (Picaxe 28x2):
'this is a picaxe 28x2 on a test board with a serial LCD for debug testing only
pause 2000
gosub clearscreen
main:
serrxd b0
if b0=104 then gosub numbersin 'consider this a "start byte" (104) is for "10-4 Good, Buddy"
goto main
numbersin:
serrxd b1
serrxd b2
SEROUT 2,T9600_8,(" ",#b1," ",#b2," ")
goto main
clearscreen:
serout 2,T9600_8,(254,1)
pause 10
return
This is a companion discussion topic for the original entry at https://community.robotshop.com/robots/show/virtual-joystick-using-processing-and-picaxe