# Strange Piicodev RGB module behaviour

**URL:** <https://forum.core-electronics.com.au/t/strange-piicodev-rgb-module-behaviour/13963>\
**Category:** Product Questions\
**Created:** [4 May 2022 09:59 UTC](https://forum.core-electronics.com.au/t/strange-piicodev-rgb-module-behaviour/13963 "2022-05-04T09:59:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony102051](https://avatars.discourse-cdn.com/v4/letter/t/ad7895/32.png) [@Tony102051](https://forum.core-electronics.com.au/u/Tony102051)\
**Post date:** [4 May 2022 09:59 UTC](https://forum.core-electronics.com.au/t/strange-piicodev-rgb-module-behaviour/13963/1 "2022-05-04T09:59:18Z")

</div>

I’m trying to integrate the PiicoDev RGB module into a small project, but I’m having difficulty getting it to “behave.” What I want is simply for it to “pulse” from dim to bright and dim again. To achieve this I simply set all the pixels to the same colour, then change the brightness value in a loop. Expected behaviour is that it will start dim at the given colour, then gradually get brighter, then get dimmer again (all on the same colour). The actual behaviour I’m getting is that randomly during the loop, the pixels will “flash” to a _very_ different colour or brightness than expected. I’ve tested each pixel so I know the individual leds in each one are all functional.  
Has anyone else experienced this?  
Am I using the functions correctly?

There doesn’t appear to be any ‘official’ documentation for it so I cannot check the library implementation: for testing and demonstration I used the one provided on the product page.  
While testing with the Python code below, various pixels changed bright green and dim blue or turn completely off in the middle of the loop (they should remain red the whole time):

```auto
from machine import Pin
from PiicoDev_RGB import PiicoDev_RGB
from PiicoDev_Unified import sleep_ms # cross-platform compatible sleep function

rgb = PiicoDev_RGB()

rgb.setBrightness(0)
rgb.setPixel(0, [255, 0, 0])
rgb.setPixel(1, [255, 0, 0])
rgb.setPixel(2, [255, 0, 0])
rgb.show()

brightness = 0
direction = 1

while True:
    brightness += 5*direction
    if brightness > 255:
        brightness = 255
        direction = -1
    if brightness < 0:
        brightness = 0
        direction = 1
 
    print(brightness)
    rgb.setBrightness(brightness)
    rgb.show()
    sleep_ms(400)

```

(for reference, I’m using a Raspberry Pi Pico. I tried swapping the cables and Pico with no change in behaviour).

---

<div class="post-metadata">

**Author:** ![Michael](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/michael/32/3545_2.png) [@Michael](https://forum.core-electronics.com.au/u/Michael)\
**Post date:** [5 May 2022 01:03 UTC](https://forum.core-electronics.com.au/t/strange-piicodev-rgb-module-behaviour/13963/2 "2022-05-05T01:03:31Z")

</div>

Hi @Tony102051, we cover a use case like this in the tutorial ([Section: Remix - Fade LEDs](https://core-electronics.com.au/guides/raspberry-pi-pico/piicodev-rgb-led-module-raspberry-pi-pico-guide/#remix))  
What is the behaviour if you try this example?

Aside, I agree that documentation-by-example isn’t the best, and so we’ll work to update the [readme](https://github.com/CoreElectronics/CE-PiicoDev-RGB-LED-MicroPython-Module) with a full API spec as per other PiicoDev modules.  
Thanks for your feedback!

---

<div class="post-metadata">

**Author:** ![James](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/james/32/4400_2.png) [@James](https://forum.core-electronics.com.au/u/James)\
**Post date:** [5 May 2022 01:33 UTC](https://forum.core-electronics.com.au/t/strange-piicodev-rgb-module-behaviour/13963/3 "2022-05-05T01:33:12Z")

</div>

Hi Tony,

I’ve run your code on the bench with a Pico and Piicodev LED module, and it works as expected (smooth pulsing of red channel, no artifacts).

If you could attach/link a video of the issue, that’d be very helpful in pinpointing your problem. Have you tried reseating the connections just in case it’s just a bad wire?

Rarely a faulty board makes it through our testing process, but it’s possible! A video will help a lot.

Keen to get to the bottom of this one!  
-James

---

<div class="post-metadata">

**Author:** ![Tony102051](https://avatars.discourse-cdn.com/v4/letter/t/ad7895/32.png) [@Tony102051](https://forum.core-electronics.com.au/u/Tony102051)\
**Post date:** [5 May 2022 03:27 UTC](https://forum.core-electronics.com.au/t/strange-piicodev-rgb-module-behaviour/13963/4 "2022-05-05T03:27:32Z")

</div>

Thanks for everyone’s input so far - I took a video but the artifacts are difficult to see because the camera is obviously staring directly into the leds (something I could probably clean up with filters and a pro setup, but my smartphone is all I have at hand).  
 ![redloop](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/6/6d58a0774e3ed9199029ead8055f9534f76702f9.gif)  
@James if you’ve run my code successfully on an identical board then I suspect I’m just chasing a red led-herring and this is just a bodgy module.

---

<div class="post-metadata">

**Author:** ![Graham](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/graham/32/54_2.png) [@Graham](https://forum.core-electronics.com.au/u/Graham)\
**Post date:** [5 May 2022 11:05 UTC](https://forum.core-electronics.com.au/t/strange-piicodev-rgb-module-behaviour/13963/5 "2022-05-05T11:05:21Z")

</div>

Hi @Tony102051,

Did you happen to have another RGB module and does the fault occur with it?

---

<div class="post-metadata">

**Author:** ![Tony102051](https://avatars.discourse-cdn.com/v4/letter/t/ad7895/32.png) [@Tony102051](https://forum.core-electronics.com.au/u/Tony102051)\
**Post date:** [9 May 2022 23:16 UTC](https://forum.core-electronics.com.au/t/strange-piicodev-rgb-module-behaviour/13963/6 "2022-05-09T23:16:23Z")

</div>

I’ve just received a big shipment of the PiicoDev RGB modules, and I can confirm that it was indeed just the one board that was dodgy, my random sampling of the other boards confirms they all perform beautifully, well done to the Core Electronics team.

I did discover that I’m better off setting the brightness only once as a “max value”, and then scaling the RGB values down from that for effect. Using the brightness register alone (after setting the colour) results in pixel 0 drifting “off colour” consistently in all the boards I tested. This indicate that the behaviour is either by design, or a gap in my (limited) understanding of the board so I’ll just wait for more documentation to come out and investigate again later.

---

<div class="post-metadata">

**Author:** ![Michael](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/michael/32/3545_2.png) [@Michael](https://forum.core-electronics.com.au/u/Michael)\
**Post date:** [9 May 2022 23:25 UTC](https://forum.core-electronics.com.au/t/strange-piicodev-rgb-module-behaviour/13963/7 "2022-05-09T23:25:59Z")

</div>

Hi Tony - when developing the firmware for the RGB module I can confirm I didn’t expect it to be used in this way. Your approach for fading LEDs is an intuitive one so we’ll make sure it works as expected in the future.  
I’ve [opened an issue](https://github.com/CoreElectronics/CE-PiicoDev-RGB-LED-MicroPython-Module/issues/2) on your behalf so we can track this update.
