Arduino: Using C to write 7 Segment 4 Bit Display Driver

I have started re-learning C using the “C Head First Book” after doing it at university a number of years ago and decided to purchase an Ardunio (Well Genunio as I am not in the USA). The first lab in the book was to create a moisture sensor for detecting if a plant needed watering and write the output to the serial port to display on the PC. I purchased quite a few components from Banggood including this 4 bit 7 segment display. I found some driver code via the bang good forums which worked but decided to write my own as I wasn’t a fan of how it was written. It is also far better to write it from scratch if you want to learn exactly how it works and not just pass variables into a pre-defined function.

How the 7 segment display works

The banggood display module has two 74HC595 shift registers on the back which controls the individual led segments on the display. A shift register is simply put a way of expanding the pins of a micro-controller, this means the display only needs 3 input PINS. The display is a 4 bit display because it has four blocks of 7 segments (excluding the dot). The schematic diagram I found for the display shows which pins of shift registers control which segments on the display. The display segments are labelled using letters A-G and DP. The below image shows which letters correspond to which segment.

Read more…

Please share 🙂