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.heartbeat(False)
    pycom.rgbled(0x7f0000) # red
    print("RED")
    time.sleep(0.25)
    
    for pins in (('P5', 'P6'),('P3', 'P2')):
    	print("..")
    
            # Not working if this line is on
    	bus=machine.I2C(0, machine.I2C.MASTER, baudrate=100000, pins=pins);
    
    pycom.rgbled(0xffffff) # white
    print("white")
    time.sleep(0.25)
    
    pycom.rgbled(0x00ff00) # green
    print("blue")
    

    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'));
    

 

Pycom on Twitter