Dave K
Published © GPL3+

RPi 7 Segment Display with a 4511IC

Raspberry Pi 7 Segment Display Driver with a CMOS 4511 IC

IntermediateProtip2 hours1,971
RPi 7 Segment Display with a 4511IC

Things used in this project

Hardware components

Resistor 1k ohm
Resistor 1k ohm
×3
Resistor 221 ohm
Resistor 221 ohm
×7
General Purpose Transistor NPN
General Purpose Transistor NPN
×4
CMOS 4511 IC
×1
5641AS
×1
Raspberry Pi 2 Model B
Raspberry Pi 2 Model B
×1

Software apps and online services

Windows 10 IoT Core
Microsoft Windows 10 IoT Core

Story

Read more

Schematics

Fritzing Sketch

Fritzing Sketch

Code

Base Constructor

C#
protected Display()
{
this.cts = new CancellationTokenSource();
this.token = new CancellationToken();
}

Display Accessor

C#
protected GpioPin[] Displays
        {
            get
            {
                return this.displays;
            }

            set
            {
                this.displays = value;
            }
        }  

Int to Binary Output Conversion

C#
protected override void SetDisplay(GpioPin displayPin, int value)
        {
            this.ClearDisplay();

            switch (value)
            {
                case 0:
                    this.SetLow(new GpioPin[] { this.pinBcd0, this.pinBcd1, this.pinBcd2, this.pinBcd3 });
                    break;
                case 1:
                    this.SetHigh(new GpioPin[] { this.pinBcd0 });
                    this.SetLow(new GpioPin[] { this.pinBcd1, this.pinBcd2, this.pinBcd3 });
                    break;
                case 2:
                    this.SetHigh(new GpioPin[] { this.pinBcd1 });
                    this.SetLow(new GpioPin[] { this.pinBcd0, this.pinBcd2, this.pinBcd3 });
                    break;
                case 3:
                    this.SetHigh(new GpioPin[] { this.pinBcd0, this.pinBcd1 });
                    this.SetLow(new GpioPin[] { this.pinBcd2, this.pinBcd3 });
                    break;
                case 4:
                    this.SetHigh(new GpioPin[] { this.pinBcd2 });
                    this.SetLow(new GpioPin[] { this.pinBcd0, this.pinBcd1, this.pinBcd3 });
                    break;
                case 5:
                    this.SetHigh(new GpioPin[] { this.pinBcd0, this.pinBcd2 });
                    this.SetLow(new GpioPin[] { this.pinBcd1,this.pinBcd3 });
                    break;
                case 6:
                    this.SetHigh(new GpioPin[] { this.pinBcd1, this.pinBcd2});
                    this.SetLow(new GpioPin[] { this.pinBcd0, this.pinBcd3 });
                    break;
                case 7:
                    this.SetHigh(new GpioPin[] { this.pinBcd0, this.pinBcd1, this.pinBcd2 });
                    this.SetLow(new GpioPin[] { this.pinBcd3 });
                    break;
                case 8:
                    this.SetHigh(new GpioPin[] { this.pinBcd3 });
                    this.SetLow(new GpioPin[] { this.pinBcd0, this.pinBcd1, this.pinBcd2 });
                    break;
                case 9:
                    this.SetHigh(new GpioPin[] { this.pinBcd0, this.pinBcd3 });
                    this.SetLow(new GpioPin[] { this.pinBcd1, this.pinBcd2 });
                    break;
                case 10:  // Clear Display
                    this.SetHigh(new GpioPin[] { this.pinBcd0, this.pinBcd1, this.pinBcd2, this.pinBcd3 });
                    break;
                default:
                    this.SetHigh(new GpioPin[] { this.pinBcd0, this.pinBcd1, this.pinBcd2, this.pinBcd3 });
                    break;
            }

            this.SetHigh(new GpioPin[] { displayPin });
        }

Clear Display Override

C#
protected override void ClearDisplay()
{
this.SetLow(this.Displays);
}

Github

https://github.com/davek17/PiSSD.Net

Credits

Dave K

Dave K

2 projects • 4 followers
Experenced C# [.net] Software Developer

Comments