The Code of this project is written in Python and is the most commonly used language to control the GPIO pins of the PI.
First we Import the Raspberry PI GPIO Library and set the mode on BCM. Then we have to define all the pins for the display as outputs.
Then we make an array of the different segments and anodes so we can use it a litle bit easier in the code later on.
Afther that we make a variable "t" that means the GPIO sends a High signal (3.3V) or "f" when a signal is Low (0V).
Setup of the outputs of the displays
Now we can create the function that decodes the numbers into wich segment that needs to be lit.
It works as following you give the function 2 variables a decimal number from 0 to 9 and a boolean (true or false) for if the decimal point (or for short DP) needs to turn on or not.
So we create a big if elif else control stucture that lights the right segment when it needs to be lit up.
When you try to give it a number that isn't a number from 0 to 9 it gives a value out of range error back.