Thursday, 5 January 2017

Raspberry Pi - 4 digit 7 Segment display, gpiozero

I recently picked up some 'retro 4 digit LED displays' from pimoroni, noticing there was no support in gpiozero for 7 segment displays (either single or multi digit) I decided to add them and create a pull request.

This builds on the code I created for driving single 7 segment displays.


Hopefully the PR will get added into a gpiozero release soon, but until then add this code to your project and use the following to drive your display.
#setup the pins

#these are the pins the LED are connected too
# (in the order A, B, C, D, E, F, G, decimal point)
LED_PINS = (7, 22, 25, 17, 8, 27, 4, 24)
#these are the pins the digits are connected too
DIGIT_PINS = (23, 18, 15, 14)

#create the multi seven segment display
# use active_high=True when digit pins are cathode (ground)
multi_sev = MultiSevenSegmentDisplay(LED_PINS, DIGIT_PINS,
                                     active_high=True)

#display your message
multi_sev.display("LEDS")

#turn off the display using
multi_sev.off()
The display function works by plexing the display, turning the LEDs on one at a time, so quickly it tricks the eye into thinking the display is showing 1 message.



No comments:

Post a Comment

Note: only a member of this blog may post a comment.