Skip to main content

Meadow.Foundation.ICs.IOExpanders.Ht16k33

Ht16k33
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet Gallery for Meadow.Foundation.ICs.IOExpanders.Ht16k33

The HT16K33 is an LED driver and key scanner. It can be used to drive up to 128 leds and is often found pre-assembled with 14-segment led displays. The HT16K33 is controlled via I2C.

Code Example

Ht16k33 ht16k33;

public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
ht16k33 = new Ht16k33(Device.CreateI2cBus());

return base.Initialize();
}

public override async Task Run()
{
int index = 0;
bool on = true;

while (true)
{
ht16k33.SetLed((byte)index, on);
ht16k33.UpdateDisplay();
index++;

if (index >= 128)
{
index = 0;
on = !on;
}

await Task.Delay(100);
}
}

Sample project(s) available on GitHub

Wiring Example

To wire a TM1637 to your Meadow board, connect the following:

TM1637Meadow Pin
GNDGND
VCC3V3
SCLD08 (SCL Pin)
SDAD07 (SDA Pin)

Class Ht16k33

Represents an Ht16k33 128 led driver and 39 key scanner

Assembly: Ht16k33.dll
View Source
Declaration
public class Ht16k33 : II2cPeripheral

Implements:
Meadow.Hardware.II2cPeripheral

Properties

DefaultI2cAddress

The default I2C address for the peripheral

View Source
Declaration
public byte DefaultI2cAddress { get; }

Fields

i2cComms

I2C Communication bus used to communicate with the peripheral

View Source
Declaration
protected readonly II2cCommunications i2cComms

Methods

Set14SegmentMessage(string)

Set a message on a 14-segment display array

View Source
Declaration
public void Set14SegmentMessage(string message)
Parameters
TypeNameDescription
System.StringmessageThe message (up to 4 characters)

Set14SegmentDisplay(char, int)

Set a single 14-segment display to a specific character

View Source
Declaration
public void Set14SegmentDisplay(char character, int displayIndex)
Parameters
TypeNameDescription
System.CharcharacterThe ASCII character
System.Int32displayIndexThe display index (0-3)

SetIsAwake(bool)

Set controller to awake / asleep

View Source
Declaration
public void SetIsAwake(bool awake)
Parameters
TypeNameDescription
System.BooleanawakeAwake if true

SetDisplayOn(bool)

Set display on or off

View Source
Declaration
public void SetDisplayOn(bool isOn)
Parameters
TypeNameDescription
System.BooleanisOnOn if true

SetBlinkRate(BlinkRate)

Set display blink rate

View Source
Declaration
public void SetBlinkRate(Ht16k33.BlinkRate blinkRate)
Parameters
TypeNameDescription
Meadow.Foundation.ICs.IOExpanders.Ht16k33.BlinkRateblinkRateThe blink rate as a byte

SetBrightness(Brightness)

Set display brightness

View Source
Declaration
public void SetBrightness(Ht16k33.Brightness brightness)
Parameters
TypeNameDescription
Meadow.Foundation.ICs.IOExpanders.Ht16k33.BrightnessbrightnessThe brightness

ClearDisplay()

Clear the display

View Source
Declaration
public void ClearDisplay()

UpdateDisplay()

Refresh the display

View Source
Declaration
public void UpdateDisplay()

SetLed(byte, bool)

Set an individual led on or off

View Source
Declaration
public void SetLed(byte ledIndex, bool ledOn)
Parameters
TypeNameDescription
System.ByteledIndexThe led index
System.BooleanledOnTrue for on
Exceptions

System.IndexOutOfRangeException
Throws if the index is out of range

ToggleLed(byte)

Toggle an led on or off

View Source
Declaration
public void ToggleLed(byte ledIndex)
Parameters
TypeNameDescription
System.ByteledIndexThe led index

IsLedOn(int)

Is led at index on

View Source
Declaration
public bool IsLedOn(int ledIndex)
Returns

System.Boolean: True if on

Parameters
TypeNameDescription
System.Int32ledIndexThe led index

Implements

  • Meadow.Hardware.II2cPeripheral