Linking Arduino with Proccesing

As I wrote in the previous post I bought a 3-axis accelerometer and I want to plot its data using Processing but first .. how do I link Arduino with Processing ?

After around 30-35 minutes of try-fail and reading the docs/forums of both softwares I came up with the solution … I’ll link them using their common Serial library.

To make a proof-of-concept … lets write a simple Arduino code that controls the on-board LED based on 2 commands received from the Serial port … if it reads “1” the LED is ON and if it reads “0” the LED is OFF.

Arduino [Show Plain Code]:
  1. span style=”color: #ff0000;”>’1′‘0’

and then lets write a simple Processing code that sends “1” and “0” with a small delay :

Arduino [Show Plain Code]:
  1. span style=”color: #ff0000;”>’1′‘0’

After you upload the Arduino code to the Arduino board and you run Processing code you should see the on-board LED blinking 🙂 Simple, huh?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.