Characteristic Locus
Inheritance System.Object > SevenSegment
Inherited Members System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone()
Namespace Meadow.Foundation.Displays.LED
Assembly SevenSegment.dll

Syntax

public class SevenSegment

Remarks

A seven-segment display is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix displays. These displays are widely used in digital clocks, electronic meters, basic calculators, and other electronic devices that display numerical information.

Purchasing

You can get 7 Segment displays from the following suppliers:

Code Example

The following example shows how to initialize a SevenSegment display and iterates through all possible characters:

using System;
using System.Threading;
using Meadow;
using Meadow.Devices;
using Meadow.Foundation.Displays.LED;

namespace SevenSegment_Sample
{
    public class Program
    {
        static IApp _app; 
        public static void Main()
        {
            _app = new MeadowApp();
            Thread.Sleep(Timeout.Infinite);
        }
    }

    public class MeadowApp : App<F7Micro, App>
    {
        public MeadowApp ()
        {
            SevenSegment 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: true
            );

            bool showDecimal = false;

            while (true)
            {
                foreach (CharacterType character in Enum.GetValues(typeof(CharacterType)))
                {
                    if (character != CharacterType.count)
                    {
                        Console.WriteLine("Character: {0}", character.ToString());
                        sevenSegment.SetDisplay(character, showDecimal);
                    }

                    Thread.Sleep(1000);
                }

                showDecimal = !showDecimal;
            }            
        }
    }
}

Circuit 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:

Constructors

View Source

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
IDigitalOutputPort portB
IDigitalOutputPort portC
IDigitalOutputPort portD
IDigitalOutputPort portE
IDigitalOutputPort portF
IDigitalOutputPort portG
IDigitalOutputPort portDecimal
System.Boolean isCommonCathode
View Source

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

Creates a SevenSegment connected to the especified IPins to a IODevice

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

Parameters

Type Name Description
IIODevice device
IPin pinA
IPin pinB
IPin pinC
IPin pinD
IPin pinE
IPin pinF
IPin pinG
IPin pinDecimal
System.Boolean isCommonCathode

Methods

View Source

SetDisplay(SevenSegment.CharacterType, Boolean)

Displays the especified character

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

Parameters

Type Name Description
SevenSegment.CharacterType character
System.Boolean showDecimal
View Source

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