Tuesday, 30 June 2020

A Bit Of Balance

So - back to teaching the kids how to code - and in the latest lesson we introduce the accelerometer. 

To start with I wanted them to see how the accelerometer behaved as the micro:bit was moved around, so we output the values to the serial port and started up the console monitor. (The example below shows the simulator, but during the lesson, we were connected to the micro:bit and viewing the remote console.)


Accelerometer To Serial
Code to write accelerometer values to serial port

Output from serial port on console monitor


Monday, 22 June 2020

Chuck a Duck - The Lesson That Never Was

Now that we'd been introduced to radio communications, the next step was to use this feature to write a game. 

I had seen the 'group teleporting duck' game on the micro bit projects page at https://microbit.org/projects/make-it-code-it/group-teleporting-duck/ and thought that would be a good basis for a game. 

This project would be a little more complicated that what we've been doing to date, so I decided to write this myself first before going through the process in a lesson.   

The idea of the game is: 

  • Each player has their own micro:bit. At startup, they can press the 'A' button to cycle through a list of id's (1-4 in a 4 player game). 
  • Once everyone has a unique number, one player starts the game by pressing the 'A' and 'B' buttons together. This transports the duck to a random micro:bit. 
  • The player that receives the duck has to shake the micro:bit to 'chuck' it to another random micro:bit. The game continues for 20 seconds and the player left with the duck at the end will lose the game. 

Friday, 22 May 2020

Talking To Each Other

Lesson 3 - this is where I thought I'd introduce the radio communications. Getting the micro:bits to interact with each other should make the lessons a bit more interesting. 

In the last post I mentioned that the boys also wanted to try programming Minecraft mods. We did try one lesson, but it was a bit of a learning curve for all of us, just working out how to connect to and run the development environment in the browser. I think I need to go away and run through it in advance otherwise progress is too slow and everyone gets frustrated. 

So I decided to carry on with the micro:bit. 

Send a Message

The first project was simply to get the micro:bits to send messages to each other. I showed them how to set up a program to show a received radio text message and then send a text message. 

They then coded the buttons to send three message (A, B and A+B). 

That was quite fun to press the button and see the message appear on the other micro:bit. 

Here's the code my eldest, Anton wrote:

 

Hide and Seek

So - we had established that the micro:bits could talk to each other. Now I wanted to establish how the signal strength could be used to determine how close to each other the micro:bits are. 

Monday, 18 May 2020

Sensor Day

The second lesson started well enough. I wanted to show the boys how they could use the sensors on the micro:bit. So we started with a very simple program to display the output from the temperature and light sensors. 


They then went into the garden, and had fun measuring the temperature and light levels. 

Monday, 11 May 2020

Hello World and Dice

So - the first project was the standard "Hello World" program - the program that every programmer always writes when they start a new language or framework. 

We went to the make code site and wrote the program. 

Hello World Program

I showed them how to save the .hex file, and then drag it to the micro:bit window's drive to install it onto the micro:bit. 

I then showed them how to pair the micro:bit, so they could download the program directly onto the micro:bit. 

So far so good. 

The Plan

Before sitting down with the boys I came up with a list of projects to go through. 

My approach was not to do the projects myself - but to go through them with the boys so we could all learn at the same time. 

Here is the list of projects I've come up with - they may change as we go on:

  • Hello World 
This should get them into the make code editor and show them how to install a program onto the micro:bit. 

  • Dice
Design different dice faces and generate a random throw when you shake the micro:bit or press a button. 
This will show them how to handle inputs, and how to display things on the LED display. I also want to introduce the use of functions early on to avoid duplicating code. 

Introduction

This blog describes how I'm teaching my 2 sons how to use the micro:bit during the Covid-19 lockdown. 

As a software developer myself, I've been trying to find ways of teaching my sons how to code.

My eldest (nearly 10 years old) was going to after school club learning scratch, so already knows some coding fundamentals.
I managed to get him to code an online tutorial simulating the corona virus and how we can flatten the infection rate curve. (https://creativesmartthings.com/simulate-a-virus-html)
He enjoyed this, but I think he just typed it in without really understanding how it worked.

My youngest (nearly 7 years old) hasn't done any coding. At the beginning of the lockdown, I introduced him to scratch. He enjoyed playing with the effects and he came up with the idea of a game moving a character through a maze and losing lives if you touch the walls. We did this together, and I think he enjoyed the process.

But with scratch they are both at different levels and I wanted to be able to sit both of them down and get them doing something together.

So I decided to buy them each a micro:bit and teach them how to code a microprocessor.