From Cycling '74 Wiki
Jump to: navigation, search

The library has to be put in your Arduino library folder in order to be used. Be careful, if you do that while the Arduino IDE is running, you have to restart the IDE in order to see the library available in your IDE.

You can find your library folder :

  • on Windows it is likely in “My Documents\Arduino\libraries”
  • on OSX, it is likely in your user “Documents/Arduino/libraries” and similarly on Linux

After having put the library in this folder, you can see it in Sketch > Import Library...


ADXL345 library is now available

BE CAREFUL: You have to upload your code without any XBee module connected!

So, I uploaded the test code by bilder at using the FTDI board connected to Arduino Fio. I wanted firstly to validate the accelerometer part first.

Here is the patch I used for this purpose:


By banging at the left top corner or loading the patch making loadbang banging that for you, you have the umenu fed by serial object (and put in good format by the small subpatcher portHandler)

You can choose the right port. Here I chose the one related to the FTDI board, still connected to the Arduino Fio.

Here is portHandler:


This takes care of the umeny building.

The subpatcher dataHandler takes care of data coming from serial port.


The object sel (abbreviation of select) selects incoming messages and fires a bang to specific output if the message equals the argument corresponding to the specific place of that output. Here, we select 10 or 13. The last output pops out the incoming message if that one doesn’t equal any argument. We also don’t want to consider new line feed (ASCII code 10). This is why we put it as an argument, but we don’t do anything if that one is selected. It is a nice trick to avoid having this message to trigger anything and even to not have it from the right output of [select]

Here, we send all message received from the Arduino, except 10 or 13 to the [zl group 78] object. This latter is a powerful list processing with many features. group argument makes it grouping messages received in a list. The last argument is here to be sure we don’t have too much elements in the list. As soon as [zl group] is triggered by a bang OR the list length reaches the length argument value, it pops out the whole list by its left outlet.

Here, we “accumulate” all messages received from the Arduino, and as soon as a carriage return is sent, a bang is sent and all data are passed to the next object.

We currently have a big list, with all data inside, each value being separated from the other one by a space character (the famous ASCII code 32 we added in the last function of the firmware)

This list is passed to [itoa] object. itoa stands for integer to ASCII. This object converts integer to ASCII characters.

The [fromsymbol] object converts a symbol to list of messages.

At last, after this [fromsymbol] we have our big list of values separated by spaces and totally readable.

Here is the compressed code you can copy-paste into a patcher to see & use this patch

-- Pasted Max Patch, click to expand. --

I used this patch to check if everything was fine.

The previous Arduino test code worked fine and as soon as I tap the accelerometer, double tap it, or let it without movement, the Arduino Fio informs me via Serial connection via Max6 and let me know his current state.

I decided to not go further and calibrate anything for now because I wanted to put it in its box to really test in real conditions.

Previous: Building and debugging Next: Xbee Setup