Processing – Serial Input

Now that we have the PROCESSING ‘Hello World’ thing happening, let’s try to get some input from the SERIAL port (USB emulation ). This is how I plan to do shiny things with the output from my arduino hack that turns the controls from my Radio Controlled planes TX Transmitter into numbers…

It seems that the first challenge will be identifying which serial port on my mac I need to address. This time I started with the PROCESSING 2 MANUAL and tinkered with the sample code under ‘serialEvent()’. After getting rid of the redundant font feckery, my little piece of code crashed and said I needed to create a directory and do a chmod 777 on it. Turns out this is business as usual to work around a port in use exception.

sudo mkdir /var/lock
sudo chmod 777 /var/lock

Tried by TERMINAL stuck on login: Reboot to fix that.

So I did. And it works. [well, after I plug my arduino into the USB port that is]. Before long I had a little text box displaying the serial data that was being written by my arduino running on the USB port.

Now, to make the output more interesting, lets find some code that does something a little more interesting with x,y (mouse) coordinates and hack that to use elevator & rudder input from my R/C TX.

  • PROCESSING File->Examples/Basics/Input/StoringInput [looks nice]
  • Modify Arduino sketch [MikeRX03_2ch_x_y] to output a pair of comma separated coordinates x,y with values between 1,1 and 1920,1080
  • Didn’t really work, need to thing about serial protocol (ie HANDSHAKE)
  • notice the range of pulse widths measured changes by about 100 from time to time. [subtract between 1240 – 1190 to make lowest values close to 1]
  • looks the goods
  •   Run: MikeRX03_4ch_CallResponseSerial.ino [no serial monitor!]
  •   Run: SerialCallResponseASCII.pde
  •            Let’s you control a dot in a window by Left TX Joystick.

Creative Commons License

Fang – Mike Seyfang



About mseyfang

Interruptus Digitalis
This entry was posted in Hobbies, phd. Bookmark the permalink.

One Response to Processing – Serial Input

  1. Pingback: Arduino – Crickets (played by Processing with minim) | a blog by Mike Seyfang

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s