Friday, November 26, 2010

I2C and sensors

I'm deep in the bowels of trying to figure out my first 'real' robotics project. More on that in future posts.

One of the things I'm trying to figure out is how to manage motors, various sensors, and different shields on my Arduino Uno. I was wondering about two arduinos being able to communicate with each other thru some sort of lightweight protocol that doesn't gobble up wads of pins. Arduino add on shields are typically hardwired to use specific pins, and there isn't any coordination between shield makers on trying to not stomp on each others pin usage. Major bummer if you want to use two shields in a project that both demand use of pin number 10. If I can spread out some of the different robot functions to multiple arduinos, I can hopefully avoid pin conflicts between shields.

Then I found I2C. I2C manages hardware thru one master device, and a series of slaves. And it uses two pins, analog 4 and 5. And a simple library (called Wiring) for implementing i2c is already built into arduinos core libraries. So you can use it to connect two or more arduinos, and have them do some simple back and forth communication.

But wait, that's not all! In addition to using it to string together arduinos, there are some sensors out there, like these guys that can be read using i2c. That allows you to string up a bunch of sensors and read them all with just two pins.

No comments:

Post a Comment