Wednesday 13 September 2017

Micro:bit and the neo pixel strip / Codebug colour star

I have 5 codebug colour stars and one code bug. But I have access to many Micro:bits through work. Here is how to connect the codebug colour star to a MIcro:bit.

You will need:


  • A code bug colour star
  • 3 x jumper cables see below, fig 1
  • 3 x Crocodile clips see below, fig 2

fig 1

fig 2
 Instructions
1. Turn the colour star so you can see the pins on the back. Attach one jumper cable to the data in pin and then attach a crocodile cable see fig 2 to the jumper cable and attach to the Micro:bit pin 0.

2. Attach the second jumper cable to the GND pin on the colour star and then attach a crocodile cable see fig 2 to the jumper cable and attach to the Micro:bit GND pin.

2. Attach the third jumper cable to the 5V pin on the colour star and then attach a crocodile cable see fig 2 to the jumper cable and attach to the Micro:bit 3V pin.

3. Attach the Microbit to your PC/Pi Open MU micro python IDE.

4. Type in the following code:


from microbit import *
import neopixel
from random import randint


np = neopixel.NeoPixel(pin0,9)

while True:
    for pixel_id in range(0,len(np)):
        red = 255
        green = 0
        blue = 0
        
        np[pixel_id] = (red,green,blue)
        
        np.show()
        sleep(200)
        np.clear() 

5. Flash the code to the Micro:bit.
 
 This version is adapted from the MIcro:bit micropython website:
http://microbit-micropython.readthedocs.io/en/latest/neopixel.html

I have changed it to loop a red light around the neopixels. (See fig 3)
                                               

                                                      Fig 3


1 comment: