Getting started with BBC Micro:bit

I have finally found time to play with my BBC micro:bit computer.

The micro:bit computer is an embedded computer given away by the BBC and comprises of an ARM processor, 25 LED matrix, accelerometer, and two input buttons.  It has Bluetooth support and connects to your PC for programming although it can also be powered by an external battery.  You need to plug it in through USB to program it through the micro:bit website.

Micro:bit connected to PC through USB showing the 25 LED programmable matrix.

In my first attempt at coding for the micro:bit I have created a program that lets you find the temperature by pressing button A, and the relative light level by pressing button B. Pressing both buttons at the same time shows a (somewhat disappointing) bar graph of the current temperature.

Source code.

I've used Microsoft Block Editor to write this code to keep things simple.  Micro bit can also be programmed in Python.  Ultimately you code needs to be compiled into object code to run on the micro:bit, but the website at handles all of this for you.

My second program is a counting ticker, useful next time you are herding sheep and need to count them back into their pen. Press button A to add one to the total.  Press B to deduct one from the total.  Shake the device to reset to zero (this is actually very easy to do by mistake).  Press both buttons to show the current count total.

Source code.

Program number 2.
That's all I have achieved for now, but I look forward to experimenting with some more challenging programs in the future.  I think I will look into the Bluetooth capabilities or research other devices that can connect with it.

In summary, the micro:bit is a fun device, although it does not compare well to the SenseHat for Raspberry Pi, or the original BBC microcomputer.  SenseHat with Raspberry Pi can pretty much do everything that the micro:bit can do with the added advantage of a much larger LED matrix (and a few extra sensors thrown in), and the BBC microcomputer is, of course, legendary.

Staying with us? Good, then you might like these varied posts on the Raspberry Pi computer, or the BBC Microcomputer.

Playing audio through Raspberry Pi

My Raspberry Pi and my BBC Master both share a 32 inch TV screen.  The problem is that I wish to continue using my Pi as a media player whilst simultaneously working with the BBC microcomputer (which doesn't play media).  In its default setting the Raspberry Pi sends audio through the HDMI to the TV and so all is very quiet when I switch to the BBC computer on SCART.

The Pi has an audio output however nothing happens when you plug an audio jack in.

A little Linux is required:

    lsmod | grep snd_bcm2835

Followed by:

    amixer cset numid=3 1

(To return to the default settings change the final '1' to '2'.)

I can now use the Pi as a media player, whilst simultaneously using my BBC computer as a productivity machine.  My music media files are stored on an external hard drive on my home network.  Altogether I am a happy nerd.

I cannot, however, force the audio through the headphones audio jack when using RISCOS on the Raspberry Pi.  I have tried changing the config.txt file by following online instructions but so far have had no luck.  If anyone knows how to do this then please get in touch.

My BBC Master 128 projects part 04

You will have been following my BBC Master computer projects series religiously.

I am trying to write some apps to turn my 30-year-old BBC microcomputer into an everyday productivity machine.  Sure, it can't handle multitasking and there is no network connection, but it is still an incredibly sophisticated machine, relatively speaking.

Today I wrote the start of the time app.  It is named 'Timely' and features various timing functions:

  • clock
  • timer
  • countdown
  • alarms
All in glorious teletext graphics.

The BBC Master has a battery-backed CMOS RAM clock, something my model 'B' computer lacked. This is an incredibly useful thing as it means that the clock stays accurate even when the machine is switched off. This might not seem that impressive when compared to modern machines, however it does make this thirty-year-old brute something of a useful machine.

Timely clock showing current time, date and a friendly message.
The timer function counts up in seconds. You can flip to the timer display by pressing button '2' and reset the timer back to 0000:00:00 by pressing SHIFT+'2'. You can switch back to the clock display by pressing '1' without affecting the timer.

The Timely timer clock 31 seconds after launching the app.
The count-down function works like the (count-up) timer, except that it is access used button '3' and reset using SHIFT-3.  You can specify the duration of the countdown from anywhere from 1 second to 1000 hours (numbers larger than this causes an overflow error, which although I think I can solve, it is unlikely that I will want to set count downs for times accurate to a second over a duration longer than 41 days!).

Setting a Timely countdown.  The countdown will generate an alert when it has finished, regardless of which mode you are currently in.
I have implemented five different user-programmed alarms.  Alarms can be set for any minute of any hour throughout the thrird Millenium.  Alarms generate an alert when they complete along with a custom message.  The difference between 'alarms' and 'countdowns' is that the alarms are saved on disk between uses of the clock.  The only problem is, of course, that the alarm will only sound if the app is actually running at the time!

Setting an alarm.
What's next?

I would like to implement:
  • hourly chimes;
  • calendar functions;
  • summary of items that are 'due' from the 'Listy' app;
  • other time/date functions, eg date of next Easter, or number of days until a due date; moon phase, position of Halley's comet, etc etc.

Well, that's it for now. You might want to roll your eyes and scroll down to this image of my floppy disk collection.

For computing history fans, these are double-sided, double-density 5 and a quarter inch disks.

The BBC disk filing system allows for up to 31 files, or about 200KiB of storage, whichever happens first.
Still scrolling down?
You might like to read about my chatbot project, or my English dictionary project, or just want to play an adventure game.