Every now and then I order something online then forget all about it until it arrives. Today one of these WIFI enabled IoT development boards arrived in the post:
I’d ordered it ages ago for less than £10 thinking it’d either make a fun project (Wifi enabled central heating controller?) or a prize for a keen student.
The thing arrived from China with no instructions at all and a quick search online didn’t throw up any beginners guides so this post will try to document my woefully inexperienced attempt at creating an IOT device.
Arduinos are tiny programmable computers that are more suited for creating Internet Of Things (IoT) devices than Raspberry Pis because you can run code in real time rather than having a complex operating system interrupting your code when it should be in the middle of some cleverly timed electronics input / output sequence to magically turn on your toaster or email you when someone presses the doorbell.
The pictured device is not an Arduino – it’s much cheaper and comes bundled with all sorts of additional geeky goodness – but it’s compatible with the excellent Arduino development tools that you can use to write and test code that looks and feels a lot like C / C++. Click here for more info about Arduinos.
Progress so far
I’ve tried to document each step of the process so far. I’ve not created a fully fledged Internet Of Things device yet but this post walks you through the stages of:
Follow these simple steps to code your own version of flappy bird on the BBC micro:bit. This tutorial is designed for someone with little or no programming experience who wants to get started writing python code. You don’t need a micro:bit to follow this tutorial, but it’s more fun if you’ve got one.
The BBC micro:bit only has a 5×5 LED screen so the graphics on our version of flappy bird are going to be predictably poor. But that means that it’s not too difficult to write (my version has 82 lines of code including comments and blank lines)
The original Flappy Bird is a really simple idea for a game that’s fun to play. By going through this tutorial you’ll learn how to understand / use the following in python:
How to display text on the micro:bit screen
How to use variables to keep track of score
How to display images on the micro:bit screen
How to scroll images on the micro:bit screen
How to detect if the user presses a button
How to keep part of your code looping
Python is a text-based programming language that’s designed to let you write as little code as possible that gets as much done as possible. There are other languages you can code a micro:bit with which are perhaps easier for beginners but once you’ve mastered the basics in python it’s much easier to create whatever you like – there’s no faffing around dragging hundreds of blocks together and using your keyboard to write code ends up being much faster than using your mouse / tapping your screen. The skills you learn in this tutorial will also help you with other python programming projects – not just those for the micro:bit.
Why the micro:bit simulator?
Testing your code on an actual BBC micro:bit is much more fun than running in in a simulator. You can use the BBC micro:bit site or the offline python editor mu to write code and send it to your micro:bit. Sometimes though, a simulator can be really useful:
It lets you test the code without having to download the .hex file and wait for it to copy to the device