Once upon a time in a faraway land there was a computer called the BBC Micro. And all the children in that faraway land (including your humble scribe) nominally learned to program on those fabled BBC Micros. And, as they say, all lived happily ever after. Or at least learned how to print rude words on a computer screen while the teacher wasn't looking.
The BBC Micro may be consigned to history, but the BBC micro:bit is no fairy tale. It's a tiny microcontroller board developed for UK schools. At its heart is an ARM Cortex-M0 processor with Bluetooth LE, coupled to a motion sensor and electronic compass. It's got a 5*5 array of red LEDs as a display and two buttons for inputs. It can also run from a battery pack via the built-in JST connector, and its edge connector has pads and rings for alligator clips and banana plugs.
We're happy to offer a variety of micro:bit equipment in Canada, including the micro:bit go bundle and many micro:bit accessories. While you can program it in many languages, I especially like MicroPython. It works really well with the Mu editor for easy and quick coding.
Here's an example script that slowly changes the colours of an 8 NeoPixel strip.
from microbit import * from random import randint import neopixel # Define a NeoPixel Strip of 8 pixels with # DATAIN connected to micro_bit pin 0 np = neopixel.NeoPixel(pin0, 8) # wheel() returns (R, G, B) tuple of colours # picked from a colour wheel from input 0..255 # converted from Adafruit example code for Arduino def wheel(pos): if pos<85: return (pos * 3, 255 - pos * 3, 0) elif pos<170: pos=pos-85 return (255 - pos*3, 0, pos * 3) else: pos=pos-170 return (0, pos*3, 255 - pos*3) k=0 while True: # endless loop k=k+1 # colour counter if k>255: k=0 # Set whole strip to same colour for pixel_id in range(0, len(np)): np[pixel_id] = wheel(k) # update strip np.show() sleep(5)
And here's a spectacularly annoying example that plays the NyanCat theme through a small speaker or piezo buzzer forever — but it gets slightly faster every time!
# nyan but it gets faster import music beats = 120 while True: music.set_tempo(bpm=beats) music.play(music.NYAN) beats = beats + 1
Have fun with your micro:bit!