In two previous posts I looked at control the :Move buggy using JavaScript Blocks or Python . In this post we are going to look at controlling the LEDs using Python (or more accurately micropython). Pin 0 controls the LEDs, they are based on 5 NeoPixel compatible, RGB, addressable LEDs; so the Neopixel protocols (and library for Neopixels) can be used. Code First five colours of the rainbow. The array lig holds the RGB settings for the rainbow colours (more details on the RGB colours can be found at Lorraine Underwood 's Halloween Cloud project ). In the code below, the five LEDs have a different colour allocated to them. from microbit import * import neopixel np = neopixel.NeoPixel(pin0, 5) lig=[[255,0,0],[255,127,0],[255,255,0],[0,255,0],[0,0,255],[75,0,136],[139,0,255]] while True: np[0] = lig[0] np[1] = lig[1] np[2] = lig[2] np[3] = lig[3] ...
Robots and getting computers to work with the physical world is fun; this blog looks at my own personal experimenting and building in this area.