Posts tagged ‘processing’

Communication with Pinguino via Bluetooth

I bought a BlueSMIRF Bluetooth module a few weeks ago, and this weekend I’ve finally had some time to put it in action 🙂

Connecting the BlueSMIRF module is really easy. The BlueSMIRF module has 6 pins: CTS-I, VCC, GND, TX-0, RX-1 and RTS-0. You have to connect CTS-I to RTS-0, connect VCC to the supply voltage and GND to ground. The TX-0 pin is connected to the RX pin of the microprocessor, while the RX-1 pin is connected to the TX pin of the microprocessor. On the PIC18F4455 these are pins 26 and 25 (pinguino pins 9 and 8). s

CTS-I  O----------------
VCC    O--5V           |
GND    O--0V (gnd)     |
TX-0   O-- to RX PIC   |
RX-1   O-- to TX PIC   |
RTS-0  O----------------

As explained in a previous post, I am using a Pinguino board, so the code should work on Arduino as well without needing too many modifications. This is the code I used for writing some text:

#define PIC18F4550
char incomingByte = 'K';	// for incoming serial data

void setup() {

void loop() {
	// send data only when you receive a C character
	if (Serial.available() > 0) {
		// read the incoming byte:
		incomingByte =;
		if (incomingByte == 'C') {
			Serial.print("I received: ");
			Serial.print(incomingByte, DEC);
In the setup routine I connect to the serial port at 115200 bauds. The bluetooth module is just used as a regular serial cable, so no fancy tricks are necessary.
On my Ubuntu laptop, I had to do the following to get things running:
  • first connect your Bluetooth dongle to the BlueSMIRF (mine appeared as FireFLY-719A)
  • sudo hcitool scan #so we know the MAC address of the FireFLY
  • rfcomm connect 0 00:06:66:03:72:9A #substitute with your BlueSMIRF’s MAC address
  • sudo gtkterm -p /dev/rfcomm0 -s 115200 #start gtkterm to read/write to the serial port

Of course we don’t want to interact through gtkterm with our microcontroller. I wanted to employ Processing, but this gave some additional difficulties in my setup. In Processing, Serial.list() is used to list all available serial ports. The Bluetooth serial port /dev/rfcomm0 does not appear in the list though. A dirty hack to solve the issue is symlinking /dev/ttyS0 to /dev/rfcomm0:

sudo rm /dev/ttyS0
sudo ln -s /dev/rfcomm0 /dev/ttyS0

If anyone knows a better way to solve the issue, please mention so in the comments! This is the Processing code:

import processing.serial.*;

Serial myPort;                // Create object from Serial class

void setup()
  size(200, 200);
  myPort = new Serial(this, Serial.list()[0], 115200);  //the first port in the list is /dev/ttyS0 which we symlinked to /dev/rfcomm0

void draw()
  while (myPort.available() > 0) {                      //if something was received via serial port
    String inBuffer = myPort.readString();

void keyPressed() {

void stop() {

February 22, 2010 at 6:12 pm 3 comments

Real time animation with Animata

I bumped into this cool open source tool Animata a few days ago. It lets you import images, define joints and bones in these images and use this skeleton to animate it. This post is a basic example of what you can do with Animata. As I am totally new to the program I could be doing some things wrong, but I already like the result 🙂

First draw some figure, and make sure the limbs are easy to separate from the body. Take a photo of it or scan it and remove the background in Photoshop or The Gimp. 

Take a photo of your drawing, remove the background in an image editor and save it as a png image

Take a photo of your drawing, remove the background in an image editor and save it as a png image

Save the image in .png format and open Animata. In the first tab you can add your image to the scene. Go to the mesh tab and put a lot of vertices on you image. Click create triangle>triangulate and you should see a lot of triangles between the vertices, click on texturize. Animata will use the vertices to warp the image into some other form (when you’ll move a joint later on).

Animata lets you define a skeleton which is used to animate the image

Animata lets you define a skeleton which is used to animate the image

Now you can define joints and bones in the skeleton tab. You’ll have to attach the vertices to one of the bones. Now you can move the joints and the figure will move along! 

You can create dummy bones the length of which changes periodically to move your figure’s limbs. The video below is a summary of the process (I cut out some parts).

Animata – a first animation from karel braeckman on Vimeo.

The really cool thing about Animata is that you can control the animation from within you own custom application by simply putting some values (x,y coordinates for the joints or the length of the bones) on a local udp port. I already have a Processing example running (by using the commands from so I’ll probably write about it in a next post.. :p

March 12, 2009 at 9:45 pm Leave a comment


Articles to be written…

Twitter – kr3l


RSS Google Reader Shared Stuff

  • An error has occurred; the feed is probably down. Try again later.

RSS Listening to..

  • An error has occurred; the feed is probably down. Try again later.