Skip to main content

Meadow.Foundation.Displays.Led.SevenSegment

SevenSegment
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet 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.

SevenSegment displays

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:

SevenSegmentMeadow Pin
portAD14
portBD15
PortCD06
PortDD07
PortED08
PortFD13
PortGD12
portDecimalD05
Common CathodeGND

It should look like the following diagram:

Wiring a SevenSegment to a Meadow F7

Class SevenSegment

Seven Segment Display

Assembly: SevenSegment.dll
View Source
Declaration
public class SevenSegment : IDisposable

Implements:
System.IDisposable

Properties

IsDisposed

Is the object disposed

View Source
Declaration
public bool IsDisposed { get; }

Methods

SetDisplay(CharacterType, bool)

Displays the specified character

View Source
Declaration
public void SetDisplay(SevenSegment.CharacterType character, bool showDecimal = false)
Parameters
TypeName
Meadow.Foundation.Displays.Led.SevenSegment.CharacterTypecharacter
System.BooleanshowDecimal

SetDisplay(char, bool)

Displays the specified valid character

View Source
Declaration
public void SetDisplay(char character, bool showDecimal = false)
Parameters
TypeName
System.Charcharacter
System.BooleanshowDecimal

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

View Source
Declaration
public void Dispose()

Dispose(bool)

Dispose of the object

View Source
Declaration
protected virtual void Dispose(bool disposing)
Parameters
TypeNameDescription
System.BooleandisposingIs disposing

Implements

  • System.IDisposable