A new (or to me at least) addition to devices you can attach a Micro:Bit to, is the Proto-Pic micro:pixel 4x8 NeoPixel board; essentially a board with 4 x8 grid of NeoPixels that you plug the Micro:Bit into. Following the advice of the website the values of RGB are all set to 32 or below to avoid pulling too much power. Pin0 is used to write to. You will need to use the Mu editor for this.
Two tests were tried
Example 1: To get the pixels to appear to light up from the last to the first one.
from microbit import *
import neopixel
np = neopixel.NeoPixel(pin0, 32)
while True:
for x in range(0, 32):
for y in range(0, (32-x)):
np[y] = (y, 32-y, 1)
if (y>0):
np[y-1]=(0,0,0)
np.show()
sleep(30)
Example 2: To randomly select a pixel and its colour.
from microbit import *
import neopixel, random
np = neopixel.NeoPixel(pin0, 32)
while True:
pxl=random.randint(0,31)
rd=random.randint(1,32)
gr=random.randint(1,32)
bl=random.randint(1,32)
np[pxl] = (rd, gr, bl)
np.show()
sleep(500)
np[pxl] = (0, 0, 0)
This is a good, fun board to play with; relatively easy to use.
All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with. Twitter @scottturneruon
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.
Subscribe to:
Post Comments (Atom)
DIY Data Science with microbits
DIY Data Science: A Complete Guide to Data Logging with the Micro:bit V1 Whether you are a STEM teacher looking for a classroom lab solution...
-
In the previous blog posts for this 'series' "It is a good time...." Post 1 looked at the hardware unpinning some of...
-
The Raspberry Pi Foundation recently released a programming activity Alien Language , with support Dale from Machine Learning for Kids , tha...
-
You don't need to buy a robot to get programming a robot, now there are a range of free and relatively simple to start with robot simula...

No comments:
Post a Comment