Remarks

SevenSegment
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Displays.Led.SevenSegment

A seven-segment display is a form of electronic display device used to show decimal numbers. These displays are widely used in digital clocks, electronic meters, basic calculators, and other electronic devices that display numerical information.

The SevenSegment driver is used to represent a 7-segment display controlled via GPIO.

The displays are simply a collection of single color leds in a pre-configured solutions. The segments are commonly referred to using letters, the top segment is A, and increase alphabetically as you move clockwise around the display. The center segment is G and the decimal or period is dp.

The pinouts vary from device to device, check the documentation to map the pinouts to a specific segment. The come in a wide selection of colors and may be common anode or common cathode.

Purchasing

You can get 7-segment displays from the following supplier(s):

Code Example

SevenSegment sevenSegment;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    sevenSegment = new SevenSegment
    (
        portA: Device.CreateDigitalOutputPort(Device.Pins.D14),
        portB: Device.CreateDigitalOutputPort(Device.Pins.D15),
        portC: Device.CreateDigitalOutputPort(Device.Pins.D06),
        portD: Device.CreateDigitalOutputPort(Device.Pins.D07),
        portE: Device.CreateDigitalOutputPort(Device.Pins.D08),
        portF: Device.CreateDigitalOutputPort(Device.Pins.D13),
        portG: Device.CreateDigitalOutputPort(Device.Pins.D12),
        portDecimal: Device.CreateDigitalOutputPort(Device.Pins.D05),
        isCommonCathode: false
    );

    return base.Initialize();
}

public override Task Run()
{
    sevenSegment.SetDisplay(character: '1', showDecimal: true);

    return base.Run();
}

Sample project(s) available on GitHub

Wiring Example

To wire a Common Cathode Seven Segment Display (like the 5161AS) to your Meadow board, connect the following:

SevenSegment Meadow Pin
portA D14
portB D15
PortC D06
PortD D07
PortE D08
PortF D13
PortG D12
portDecimal D05
Common Cathode GND

It should look like the following diagram:

Characteristic Locus
Inheritance System.Object > SevenSegment
Namespace Meadow.Foundation.Displays.Led
Assembly SevenSegment.dll

Syntax

public class SevenSegment : object

Constructors

SevenSegment(IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort, Boolean)

Creates a SevenSegment connected to the especified IDigitalOutputPorts

Declaration
public SevenSegment(IDigitalOutputPort portA, IDigitalOutputPort portB, IDigitalOutputPort portC, IDigitalOutputPort portD, IDigitalOutputPort portE, IDigitalOutputPort portF, IDigitalOutputPort portG, IDigitalOutputPort portDecimal, bool isCommonCathode)

Parameters

Type Name Description
IDigitalOutputPort portA

Digital input port for pin A

IDigitalOutputPort portB

Digital input port for pin B

IDigitalOutputPort portC

Digital input port for pin C

IDigitalOutputPort portD

Digital input port for pin D

IDigitalOutputPort portE

Digital input port for pin E

IDigitalOutputPort portF

Digital input port for pin F

IDigitalOutputPort portG

Digital input port for pin G

IDigitalOutputPort portDecimal

Digital input port for decimal pin

System.Boolean isCommonCathode

Is the display using common cathod (true) or common annode (false)

SevenSegment(IPin, IPin, IPin, IPin, IPin, IPin, IPin, IPin, Boolean)

Creates a SevenSegment connected to the especified IPins to a IODevice

Declaration
public SevenSegment(IPin pinA, IPin pinB, IPin pinC, IPin pinD, IPin pinE, IPin pinF, IPin pinG, IPin pinDecimal, bool isCommonCathode)

Parameters

Type Name Description
IPin pinA

Pin A

IPin pinB

Pin B

IPin pinC

Pin C

IPin pinD

Pin D

IPin pinE

Pin E

IPin pinF

Pin F

IPin pinG

Pin G

IPin pinDecimal

Pin decimal

System.Boolean isCommonCathode

Is the display using common cathod (true) or common annode (false)

Methods

SetDisplay(SevenSegment.CharacterType, Boolean)

Displays the specified character

Declaration
public void SetDisplay(SevenSegment.CharacterType character, bool showDecimal = false)

Parameters

Type Name Description
SevenSegment.CharacterType character
System.Boolean showDecimal

SetDisplay(Char, Boolean)

Displays the especified valid character

Declaration
public void SetDisplay(char character, bool showDecimal = false)

Parameters

Type Name Description
System.Char character
System.Boolean showDecimal