Easy way to fade the on-board LED?
-
Hi,
I want to fade the on-board LED from off to full brightness (preferably in a color of choice). Is there an easy way to implement this?
I want to use a for loop, however I'm not sure how to do that with the HEX value formating for the LED (e.g. from 0x00000 to 0xffffff)
Thanks!
-
@mahe
for this puropose you can use HLS color scheme and manipulate brightness
e.g. use this lib
https://github.com/Benhgift/micro-color-clock/blob/master/hls.py -
Thanks! I couldn't figure it out (quite new to python).. Ended up with this:
def rgb_to_hex(red, green, blue): """Return color as #rrggbb for the given color values.""" return '%02x%02x%02x' % (red, green, blue) for i in range(256): color = rgb_to_hex(i,i,i) pycom.rgbled(256-int(color,16)) time.sleep(0.005)This just fades from white to off, removing the '256' fades from off to white.. Probably not the smoothest way to do it, but it works. :)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login