By default the heartbeat LED flashes in blue colour once every 4s to signal that the system is alive. This can be overridden through the
import pycompycom.heartbeat(False)pycom.rgbled(0xff00) # turn on the RGB LED in green colour
The heartbeat LED is also used to indicate that an error was detected.
The following piece of code uses the RGB LED to make a traffic light that runs for 10 cycles.
import pycomimport timepycom.heartbeat(False)for cycles in range(10): # stop after 10 cyclespycom.rgbled(0x007f00) # greentime.sleep(5)pycom.rgbled(0x7f7f00) # yellowtime.sleep(1.5)pycom.rgbled(0x7f0000) # redtime.sleep(4)
Here is the expected result: