A simple graphing program using Processing

A little while ago I was playing with some sensors I had, and though how nice it’d be if I could graph their outputs on my computer. So I wrote a simple program in the Processing language to do just that. Although the code I wrote was able to get strings of data from my Arduino, the code I am posting here is somewhat stripped out to be as understandable as possible to beginners. Instead of displaying data from sensors, this program graphs your mouse’s x- and y-coordinates. It is still capable of plotting data from sensors, but you’ll have to write the code to fetch and handle the data. As is explained in the comments in the code, there are three variables (integers) to store incoming data points (newDataPoint1, newDataPoint2 and newDataPoint3), each of which corresponds to one of the graphs. Your data-handling code will have to feed each of these variables one new integer each iteration of the draw loop in order for this program to function properly. Currently, newDataPoint1 and newDataPoint2 are being set to the mouse’s x- and y-coordinate respectively and newDataPoint3 is just set to “0” (not being used). Thus for users with a little experience with Processing it should be quite easy to modify this code to your needs.

Here’s what it looks like (the blue line at the top is the third graph which is currently not being used):

Continuous Graph

Before you can run my code, you’ll have to download and install Processing. Once you have done that, you can download my code here (click to view, right-click and “Save As” do download).


Using a USB host shield and a Bluetooth dongle to get data from a PS3 controller – Success!

As mentioned in a previous post, I’m interested in using a PS3 controller as the remote for future projects/robots. Having received all of the required hardware, I decided to make this video explaining the process of setting up the PS3 controller and Arduino for communication via Bluetooth. See below the video for details. UPDATE: The latest USB host library does not print out any debug information, so you won’t see any of the information that is printed out below “Bluetooth Library Started.” You should still be able to connect your PS3 controller and see it’s data output in the terminal.

Hardware (besides an Arduino):

A Sony-made, PS3 controller (Dualshock 3 or Sixaxis (I was unable to find a strictly Sixaxis controller)).

A USB host shield: Circuits@home and Sparkfun.

A Bluetooth dongle: UPDATE: Go here for the list of dongles confirmed working by the developers. The wiki page for using a PS3 controller will have a list of compatible dongles (although note that in the video I mention that one of the “supported” dongles doesn’t in fact work). Here are the two I have: The black one (working) and the green one (not working, although listed as compatible). These are also confirmed working (by the developers): Kingston and Zoom.

This dongle has also been confirmed working: http://www.amazon.com/gp/product/B007Q45EF4/ref=oh_aui_detailpage_o08_s00?ie=UTF8&psc=1

A user has confirmed that the Hytac HGB737 bluetooth dongle works as well.

The Software (besides the Arduino IDE):

UPDATE: Some people have had trouble with the newer versions of the USB host shield library. The new library does not print out the debug information you see in my video and the sketch will become too large to upload to an UNO if you turn the debugging on. If you would like to use the exact same version I use in my video (and am still using), you can get it here. You can get the latest version of the USB host shield library below.

You will need to download the entire USB host shield library from GitHub. This is a direct download link, but if you’d like to take a look around the repository go here.

Install the library as you would any other (if you haven’t done this before see this page), and open the “PS3BT” example as I show in the video (File –> Examples –> (Whatever you named the library) –> Bluetooth –> PS3BT). Remember that the Arduino doesn’t allow for dots (.) or dashes (-) in the library folder name, so when you download the library (which for some reason does have dots and dashes in its folder name) you will have to rename for the Arduino IDE to recognize it.

If there is something I forgot to include here, or if you have a question about something in the video, please ask.