I've been tinkering with the new BBC micro:bit computer, especially the Micro Python editor Mu.
I love how flexible the board is, especially for getting down to hacking in very little time.
To test out the micro:bit I thought that I would write a simple script to blink the lights after the unit has been shaken.
Yes the micro:bit has an accelerometer that can be used to detect a gesture, such as a shake.
So with an LED attached to pin 0 and the Mu application loaded on my Linux machine, I wrote a few lines of code.
from microbit import * def blinky(): for i in range(10): pin0.write_digital(1) sleep(500) pin0.write_digital(0) sleep(500) while True: if accelerometer.was_gesture("shake"): blinky()
I then clicked on Flash to write the code to my micro:bit and after a few moments I shook the board and triggered my LED to blink 10 times.