Skip to content

class to use common cathode RGB LEDs with the MCP23017 board

License

Notifications You must be signed in to change notification settings

SamSkjord/MCP23017-RGB-Class

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RGBLED Class:

COLOUR_MAP:

A dictionary mapping colour names to their respective RGB pin states.

red, green, blue,

yellow cyan magenta,

white, off

Initialization:

The init method initializes the MCP23017 pins for the red, green, and blue LEDs and sets up predefined blink and solid methods using partial for each colour.

set_colour: Sets the colour of the RGB LED by turning the appropriate pins on or off based on the colour name.

off: Turns off all the LED colours.

blink: Blinks a specific colour by setting the colour, waiting for a duration, then turning it off and waiting again.

blink_between: Blinks between two colours by setting the first colour, waiting, setting the second colour, waiting, then turning off.

solid: Sets a solid colour that remains until it is changed or turned off.

Main Loop:

The loop cycles through various colours by calling the predefined blink methods directly.

It demonstrates blinking between two colours by name.

It sets a solid colour (blue) for 2 seconds, then turns off the LED for 2 seconds.

This implementation allows you to call methods like rgb_led.solid_blue(), rgb_led.solid_off(), rgb_led.blink_red(), and rgb_led.blink_between('red', 'green') for easy and clear colour control.

About

class to use common cathode RGB LEDs with the MCP23017 board

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages