WS2812 RGB led ring example on Microbit with Edublocks

This was a WS2812b led ring that I purchased for low cost. There are 12 LEDs in total on this and once you solder 3 cables to the module you are ready to go

Connect Vcc to MIcro:Bit 3.3 volts, Gnd to Gnd and the In to MIcro:Bit 0,

Open Edublocks and create the following

 

Here is the python code that is created

np = None
 
 
from microbit import *
import neopixel
np = neopixel.NeoPixel(pin0,12)
while True:
  for red in range(12):
    np[red] = (255,0,0)
    np.show()
  sleep(500)
  for green in range(12):
    np[green] = (0,255,0)
    np.show()
  sleep(500)
  for blue in range(12):
    np[blue] = (0,0,255)
    np.show()
  sleep(500)

 

Download

Downloads

A first look at edublocks and the Micro:bit

We will look at an easy to use IDE called edublocks. Here is the blurb

EduBlocks for micro:bit is the latest edition. It’s a drag and drop code editor based on MicroPython. It includes most MicroPython features that allows you to control the onboard micro:bit features as well as external components.

You can see the editor at https://microbit.edublocks.org/

We will create a simple example that scrolls a letter depending on the button pressed, in Edublocks this example looks like this

You select a category from the left, for example Basic , find teh block you wish to use and drag the block into the main screen. As you can see these are colour coded.

Once complete you can save this as xml, export the python file and also download a hex file. To program your MIcro:bit, connect it to your computer via a USB cable and it will appear as a drive, copy the hex file and it will be downloaded to the micro:bit. Now press the A and B buttons.

As a matter of interest here is the python code that is exported from the example above

from microbit import *
while True:
  if button_a.is_pressed():
    display.scroll("A")
  elif button_b.is_pressed():
    display.scroll("B")

 

A nice easy to use online environment that can export in python