Notes About Working with Various Arduino & Netduino Microcontroller Boards

Tuesday, November 20, 2012

Changing the I2C Address of a Sparkfun 7-Segment Serial LED Display

Because the breakout board attached to the Sparkfun 7-Segment Serial LED Display includes connections for UART (TTL serial), SPI, and I2C, they are easy to include in a variety of applications.

For a quick example of how to use this display, see my Nov. 7th posting.

I wanted to use a couple connected using I2C because I2C allows chaining multiple devices using just 2 data wires to pins on the Arduino (plus the 5V & GND wires). When using miltiple I2C devices, each has to have a unique address. The Sparkfun LEDs all have the same default address (0x71), so they have to be changed.

Following the special commands document, I connected the first one using TTL serial to reset the I2C address and then switched to an I2C connection for use. You don't have to connect in TTL serial mode, though, just to reset the I2C address. The following code snippet shows how to do this, assuming that SDA is connected to Arduino pin A4 and SCL to A5.

Keep in mind that since the boards have the same initial address (0x71), they will have to have their addresses changed individually. The board stores the address in non-volatile memory, so the new address will stay in effect until you change it again.

#include <Wire.h>

#define CHANGE_ADDR_CMD  0x80
#define DEFAULT_ADDR     0x71
#define NEW_ADDR         0x03 // Value between 0x01 and 0x7E

void setup() {

No comments:

Post a Comment