Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Easy way to fade the on-board LED?

    Scheduled Pinned Locked Moved LoPy
    lopyledrgbledfade
    3 Posts 2 Posters 1.8k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      mahe
      last edited by

      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!

      L 1 Reply Last reply Reply Quote 0
      • L Offline
        livius @mahe
        last edited by livius

        @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

        think about people first, then computers

        M 1 Reply Last reply Reply Quote 1
        • M Offline
          mahe @livius
          last edited by

          @livius

          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. :)

          1 Reply Last reply Reply Quote 0

          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
          • 1 / 1
          • First post
            Last post

          Pycom on Twitter

          Pycom