Skip to content
Ho Yun "Bobby edited this page Sep 8, 2020 · 11 revisions

We've written loads of example sketches that explain how to interface an Arduino with a Serial 7-Segment Display. You can find them in the firmware/Serial 7-Segment Display/Arduino_Examples folder of this repo.

All of the Arduino sketches listed below are provided under the Beerware license. It's all public domain, free to use, modify, whatever. If you find it useful, and we meet some day, buy us a beer!

Serial Examples

The following example sketches show how you could use the Arduino's hardware or software UARTs to interface with the S7S:

For all example sketches, Arduino's software serial library is used. The display should be powered off 5V, and pin 8 of the communicating Arduino should be connected to the display's RX pin.

Arduino Pin Serial 7-Segment Display Pin
7 (Software RX) TX
8 (Software TX) RX
5V VCC
GND GND
Connecting to the display's TX pin is optional. Communication from Arduino to display should only be one way.

The display's RX pin is located in two places - on the top header and on one of the sides. The side pin is mostly intended to be connected to an FTDI board, but you could connect to either of those pins.

This is example code that shows how to display basic numbers on the display.

Aside from showing a number of methods for printing data, this sketch also provides a good example on how to use the clear display command.

This code expects the display to be listening at 9600bps. If your display is not at 9600bps, you can do a software or hardware reset. See the Wiki for more info.

This example code shows how to control the brightness and other system settings on S7S. This code alternates the display's brightness settings between 0%, 50%, and 100% brightness.

Note that the brightness setting is stored in EEPROM. So whenever the display loses power, the next time it's turned on it'll retain the brightness value last sent to it.

This is example code that shows how to display basic numbers and control the decimal, colon, and AM/PM dot.

This is a useful bit of code if you're looking to make a digital clock. As is seemingly standard with digital clocks, the colon should blink on and off to indicate passing seconds. The apostrophe dot in the upper right will indicate either AM or PM.

This example code shows how to control the baud rate and other settings on the S7S. Open the serial monitor at 9600bps to start the program.

Did you set your Serial7Segment display to a baud rate you don't know? This example sketch should get you fixed up! This example code sends the factory reset command at 12 different baud rates.

SPI Examples

These examples show how to use the display over SPI. Both examples use the Arduino SPI library.

Because we use the SPI library, you'll need to connect the Arduino's hardware SPI pins to the display.

Arduino Pin Serial 7-Segment Display Pin
10 (CS) SS (with a bar over it)
11 (MOSI) SDI
13 (SCK) SCK
5V VCC
GND GND
Connecting the displays *SDO* pin to MISO (12) on the Arduino is not required. Communication only goes one way - from Arduino (master) to display (slave).

This is example code that shows how to send data over SPI to the display.

This is example code that shows how to send data over SPI to the display.

I2C Examples

The following examples show how to use Arduino's hardware I2C pins to control the Serial 7-Segment Display. Both pieces of code use the Wire library to send the I2C data.

You should connect the display to the Arduino's I2C pins. Connect SDA's to SDA's and SCL's to SCL's. On older Arduino's, without the designated SDA and SCL pins, A4 is SDA and A5 is SCL.

Arduino Pin Serial 7-Segment Display Pin
SDA (A4) SDA
SCL (A5) SCL
5V VCC
GND GND

SDA and SCL on the display are located on both sides. You can connect to pins on either side, these pins are connected together.

The I2C interface specifies pull-up resistors. You shouldn't need those, as the Wire library makes use of the ATmega328's internal pull-up resistors. If you have multiple I2C devices on the same bus or need to use faster SCL data rates 4.7k pull up resistors are recommended on SDA/SCL.

Also make sure to power the display at 5V!

On all examples the display's address is assumed to be the default - 0x71. If you've modified that value on the display, then make sure to change it in the example code.

Please Note: 0x71 is the 7-bit I2C address. If you are using a different language than Arduino you will probably need to add the Read/Write bit to the end of the address. This means the default read address for the OpenSegment is 0b.1110.0011 or 0xE3 and the write address is 0b.1110.0010 or 0xE2. For more information see our I2C tutorial.

The Serial7Segment firmware and OpenSegment support standard 100kHz and fast 400kHz I2C SCL speeds. Use the following code in Arduino to enable 400kHz fast I2C speed:

Wire.begin(); //Join the bus as master
//By default .begin() will set I2C SCL to Standard Speed mode of 100kHz
Wire.setClock(400000); //Optional - set I2C SCL to High Speed Mode of 400kHz

This is example code that shows how to send data over I2C to the display.

This is example code that shows how to control the brightness level of the display over I2C.


Datasheet Links: