Arduino Mega / Firmata - pins above 21?

Hi,

I’m using an Arduino Mega board with Standard Firmata, and I want to access the digital pins above 21. I’ve included “ofArduino.h” and can access pins 2-21 fine as described in the openframeworks example, but whenever I try to use the higher pins it crashes.

I’ve set the pins up like this:

for (int i = 1; i < numPins; i++)
{
a.sendDigitalPinMode(i, ARD_INPUT);
}

and accessed them like this:

int x = a.getDigital(4);

But whenever I try to set up (i.e. numPins > 22) and access pins above 21 everything crashes…

I’ve tested the board using a Firmata Test program (which can be found here http://www.pjrc.com/tmp/firmata/readme.html) and all the pins work fine, so the problem is either in ofArduino, or more likely that I’m doing something wrongly in my openframeworks code…

Any help would be much appreciated!

Duncan

Looks like ofArduino needs to be updated to work with the Mega, if you look at the top of OF61 ofArduino.h you’ll see:

  
// ---- arduino constants (for Arduino NG and Diecimila)  
  
// board settings  
#define ARD_TOTAL_DIGITAL_PINS							22 // total number of pins currently supported  
#define ARD_TOTAL_ANALOG_PINS							8  
#define ARD_TOTAL_PORTS                                 3 // total number of ports for the board  
  

Shouldn’t crash really, but I can take a look at updating it for the Mega when I get home and grab my Mega.

Sorry, just realized I’ve left my Mega in a different state. Have you had any luck getting it working?