7 Segment displays¶
-
class
electronics.devices.sevensegment.
SevenSegmentGPIO
(segments)¶ Class for driving a single character 7 segment display connected to GPIO pins
This class only works with 8-pin 7 segment displays (not multiplexed in any way). Connect a gpio pin to every segment pin of the display and connect to common anode or cathode to vcc or gnd.
Initialize this class with the pins in this order:
- top segment
- top left segment
- top right segment
- middle segment
- bottom left segment
- bottom right segment
- bottom segment
Example: >>> # Connect to a MCP23017 port expander because we need 7 GPIOs >>> expander = MCP23017I2C(gw) >>> display_pins = expander.get_pins()[0:7] >>> # Create a SevenSegmentGPIO instance for the display >>> display = SevenSegmentGPIO(display_pins) >>> # Display a number >>> display.write(6) >>> # Letters are also supported >>> display.write('h')
-
write
(char)¶ Display a single character on the display
Parameters: char (str or int) – Character to display