张高兴的 Windows 10 IoT 开发笔记:使用 MAX7219 驱动数码管
This is a Windows 10 IoT Core project on the Raspberry Pi 2/3, coded by C#.
GitHub:https://github.com/ZhangGaoxing/windows-iot-demo/tree/master/MAX7219_7Segment
Image
Connect
- DIN - MOSI
- CS - CS0
- CLK - SCLK
- VCC - 5V
- GND - GND
Reference
https://github.com/ZhangGaoxing/windows-iot-demo/tree/master/MAX7219/Reference
What Contains
In MAX7219.cs file
///
/// Initialize MAX7219
///
public async Task InitializeAsync();
///
/// Set Register Data and Print
///
/// Segment index, range from 0 to 7
/// Printed data
/// Does it show Decimal Point (Only for DecodeMode is Digit7)
public void SetSegment(int index, byte value, bool isDecimal = false);
///
/// Set MAX7219 Decode Mode
///
/// Mode
public void SetDecode(DecodeMode mode);
///
/// Set Brightness
///
/// In range 0-16
public void SetIntensity(int val);
///
/// Test Display
///
/// Mode
public void DisplayTest(DisplayTestMode mode);
///
/// Set MAX7219 Power
///
/// Mode
public void SetPower(PowerMode mode);
///
/// Clear the Segment
///
public void Clear();
///
/// Cleanup
///
public void Dispose();
How to Use
- First, you need to create a MAX7219 object. After that you should call InitializeAsync() to initialize.
MAX7219 led = new MAX7219(0, DecodeMode.Digit7);
await led.InitializeAsync();
led.SetIntensity(5);
- Secondly
for (int i = 0; i < 8; i++)
{
led.SetSegment(i, (byte)i);
}
- If you want to close the sensor, call Dispose().
led.Dispose();