Add an accelerometer to meggy?

11 views
Skip to first unread message

Tony DiCola

unread,
Feb 26, 2010, 4:46:29 PM2/26/10
to megg...@googlegroups.com
Hey all I recently put together a meggy jr. kit and am really enjoying it.  I was curious though, has anyone mounted an accelerometer to their meggy so they can create tilt sensitive games?  I saw this EMSL article that seems to have all the details for adding a cheap accelerometer to arduino: http://www.evilmadscientist.com/article.php/ADXL335  Would there be any issues adapting this to the meggy jr?  I should just be able to solder to the exposed pads for ADC input on meggy jr., right?  Is there a good spot on meggy to mount external boards like an accelerometer?  Thanks!
 
-Tony

Emo

unread,
Feb 26, 2010, 5:29:30 PM2/26/10
to MeggyDev
As it turns out, the 6 buttons on the Meggy use the 6 available ADC
pins on the processor, so you would have to basically sacrifice some
(3) buttons to do this! In a posting discussion here earlier (about
using the ISP as a second serial port), I learned there could be some
potential workarounds to re-configuring how the buttons are connected
to the system, but it would take some work (note that it is possible,
though). It seems the best option to re-route the buttons would be to
use a multiplexer chip and interface it with the remaining ADC pins on
the processor. In addition to that, you would need to customize the
library to take this into account, which you could do at the same time
you write the code to interface with the accelerometer. I have no
experience with this thusfar, but some of the other [more
knowledgeable] folks around here might be able to give some more
detailed, solid advice.

Sounds like a fun project! :)
-Emo

Windell H. Oskay

unread,
Feb 26, 2010, 5:51:11 PM2/26/10
to megg...@googlegroups.com


I have not heard of anyone adding an accelerometer yet, but it's certainly
possible and something that I'd like to see.

The 6 ADC-capable inputs are normally used for the six buttons. When you
press one of the buttons, that connects one of those signal lines to
ground. However, when the buttons are not pressed, the buttons are simply
not part of the circuit. So... if you were building a Meggy Jr without
buttons or just didn't press them, you could just wire it up as in that
tutorial, with the buttons still in place. (No damage will occur from
shorting the accelerometer outputs to ground; that's specified in its
datasheet.) The one thing that you'd need to keep in mind is that the
accelerometer requires a lower-voltage power supply... so you might want
to consider adding a tiny 3.3 V regulator as well.

If you want to use both the buttons and the accelerometer at the same time
that requires more care-- if you need to clearly distinguish a button
press from a "railed" signal on the acceleration.

So what you would want to do (ideally) is put a couple of voltage
dividers on the 5 V to give you 0.25 V and 3.5 V power rails that can go
to the accelerometer, as its "gnd" and "vcc" supplies, respectively.
Then, connect the three outputs to three Meggy analog inputs through 1k
resistors. Having done this, the input value on the Meggy will read 0 V
only when the button is pressed. When the button is not pressed, there
will be a valid analog signal between 0.25 V and 3.5 V at the input.

As far as where to put it all... well, that's a harder question. :)
One way might be to build a "backpack" board for the Meggy Jr that takes
the place of the existing rear cover plate.

-Windell

Tony DiCola

unread,
Feb 27, 2010, 1:37:57 AM2/27/10
to megg...@googlegroups.com
Thanks for the advice!  I'll have to order an accelerometer breakout board and play around with it a bit.  If pins are really an issue would building a more advanced breakout board with a microcontroller to monitor the accelerometer and communicate with meggy through I2C, etc. be an (expensive) option?
 
-Tony

--
You received this message because you are subscribed to the Google Groups "MeggyDev" group.
To post to this group, send email to megg...@googlegroups.com.
To unsubscribe from this group, send email to meggydev+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/meggydev?hl=en.


Windell H. Oskay

unread,
Feb 27, 2010, 4:55:12 AM2/27/10
to megg...@googlegroups.com

On Feb 26, 2010, at 10:37 PM, Tony DiCola wrote:

> Thanks for the advice! I'll have to order an accelerometer breakout board and play around with it a bit. If pins are really an issue would building a more advanced breakout board with a microcontroller to monitor the accelerometer and communicate with meggy through I2C, etc. be an (expensive) option?

Since I2C lives on the same pins as the analog inputs, there really wouldn't be much advantage to that approach.

One non-invasive approach with an external board would be to use a tiny microcontroller that reads out the three analog inputs from the accelerometer and sends them -- over the serial port -- to the Meggy Jr RGB.

The microcontroller could be as simple as an ATtiny10 that bit-bangs its data to the RX pin of the Meggy, and there are a lot of other ways to do that as well.

-Windell

Reply all
Reply to author
Forward
0 new messages