# A week with Micro:bit

7 thoughts
last posted Dec. 31, 2015, 3:11 p.m.
0
get stream as: markdown or atom
0

# Meet Mei-Xiu

Sent to me by its previous host, Stewart Watkiss :) Haven't flashed the device yet so it looks like the robot controlling hex is still loaded.

More from Mei-Xiu

0

# Environment setup

Started using upyed and Tom Viner's very convenient upyflashed. The tool was exiting with a trace in the event of no hex files being available, so I opened a PR to make this a bit better.

EDIT: Turns out my "fix" was skipping the sleep step which caused the loop cycles to be a bit too fast. Good thing Tom caught that ;)

0

The Micro:bit gets a warm Christmas welcome by some of the other flashing LEDs in our house.

0

# Project #1: Dice roller

So the plan is to make a simple dice roller application.

• The buttons should cycle through the various dice from a simple standard RPG poly set (d4, d6, d8, d10, d12, d20)
• Once a die is selected the player should be able to roll it by shaking the micro:bit.

Possible difficulties:

• Find a way to distinguish the rolling motion from other types of movement. My gut tells me this will be through detecting certain types of acceleration.

## Continued...

I didn't get the chance to work on this yesterday due to Christmas preparations but today I got a couple of hours playing with the Micro:bit again :)

Back to detecting dice rolling, turns out this wasn't too hard but I did need to play a little bit with calibrating the thresholds for detecting consecutive changes in acceleration. There are probably more precise ways to do this, but it works for now!

I created a repo for the rest of the Micro:bit projects and this is the code for the dice roller.

I just realised this is very similar to what Martin O'Hanlon did with his 8-ball shuffle, our solution was actually pretty similar. I had to add some time thresholds as well, otherwise the shake event ended up happening way too easily and offset.

0

# Project #2: Snowflakes (almost)

Since Christmas often means snow (at least for us living in the northern hemisphere) I thought to try to generate some snowflakes on the microbit.

Since snowflakes are symmetrical, we should only have to create a 3x3 corner and rotate that 45° at a time that to get the full shape. End result might resemble a star-wars spaceship instead of snowflakes. Equally seasonal?

Here's how it looked like:

and here's the code.

0

# Project #3: Plants have feelings too

I have recently been pretty bad at keeping my house plants alive. I need to add reminders to take care of my plants, and I usually end up ignoring them as "I'll do it when I get home", and then I almost never do. Wouldn't it be nice if the plant could tell you that it needs attention?

Plants don't have faces to express themselves, so what if the micro:bit could work for that purpose?

Excluding cacti, the one thing that plants usually need the most is ground moisture. How is moisture measured? The internet says that conductivity is a pretty good indicator.

So with a simple Ohmmeter we could measure the increase/decrease in resistance and by setting a few reasonable thresholds we can tell what the resistance corresponds to in terms of moisture levels.

Tools used:

• 3 cables with alligator clips
• 2 galvanised (I think) nails.
• 1 resistor (~1.2KΩ)

The nails were used as ground probes, one connected to power and one connected to pin0. The resistor was used as the "known" resistor for the ohmmeter. To replicate this you could use any resistor/ground probes/cabling. Just make sure the code is adapted for the resistor and that the probes are resistant to corrosion.

Also it goes without saying that you should keep the micro:bit at a safe distance from water and dirt ;)

In terms of programming, I set the micro:bit to display a happy, ok or sad face depending on the value of the resistor. Finding the correct thresholds was tricky as they can vary depending on the soil, distance between the probes etc. (code)

So, without further ado here's a watering demo of one of my plants (which I kept without water for a few days for that purpose as you can see from its horrible condition!):

As you can see with a bit of watering the plant becomes "OK" and with a bit more it becomes "Happy" ;)

A few potential extensions to this project (probably more important for outdoor plants...):

• Light detector
• Temperature detector
0

# Bye Mei-Xiu!

I'm packing Mei-Xiu today to send to its next host, Päivi Suomela. I'm really looking forward to seeing her next adventures :)

Follow the rest of her trip on the microworld tour website!