rgbled does not change collor if I2C is used

  • I have this strange case with a code of mine on WiPy3. I am unable to change RGB led colors in my boot.py file.

    This is my code:

    import machine
    import network
    import pycom
    import os
    import time
    import ujson
    import sys
    import gc
    pycom.rgbled(0x7f0000) # red
    for pins in (('P5', 'P6'),('P3', 'P2')):
            # Not working if this line is on
    	bus=machine.I2C(0, machine.I2C.MASTER, baudrate=100000, pins=pins);
    pycom.rgbled(0xffffff) # white
    pycom.rgbled(0x00ff00) # green

    Once I comment out "bus=machine.I2C(0, machine.I2C.MASTER, baudrate=100000, pins=pins);" wipy RGB led works fine and colors are switching from red to white to green. But if I have I2C line, it stays on red.

    How can I fix this?

  • administrators

    @kaspars said in rgbled does not change collor if I2C is used:

    bus=machine.I2C(1, machine.I2C.MASTER, baudrate=100000, pins=('P3', 'P2'));

    The RGB LED is using P2. If you use P2 for I2C, it is no longer able to control the RGB LED.

    See https://docs.pycom.io/chapter/datasheets/development/wipy2.html as an example, this applies to all our modules.

  • It seems that these two pins cause the issue:

    bus=machine.I2C(1, machine.I2C.MASTER, baudrate=100000, pins=('P3', 'P2'));

Log in to reply

Pycom on Twitter