The Mu Python editor’s new plotter function continues to delight me. I connected a Monk Makes Sensor Board to a micro:bit and wrote a few lines of Python to see whether I could get some live data readings from its three sensors: sound, heat and light. And by golly, it works!
Here’s the Python program I used. I opened the REPL and plotter in Mu and then flashed this code onto a micro:bit with the sound, temperature and light sensors attached to pins 0, 1 and 2 respectively:
from microbit import * while True: sleep(20) pin0reading = pin0.read_analog() # sound - blue line pin1reading = pin1.read_analog() # temperature - green line pin2reading = pin2.read_analog() # light - orange line print((pin0reading, ((pin1reading-400)*5), pin2reading))
I messed around with the temperature reading a bit to get it to scale, you could probably do a better job. The video below shows the board in action with live-plotting. It’s only (at the time of writing) £7.20 from CPC, a real bargain for three sensors in one easy-to-use board.
You can download the beta version of Mu 1.0 for your OS of choice using the links at the foot of this Github page.