# 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. ![DSC_0033.JPG](/media/347/DSC_0033.JPG) [What is this all about?](http://microworldtour.github.io/about.html) [More from Mei-Xiu](http://microworldtour.github.io/microbit/meixiu.html) ---- # Environment setup Started using [`upyed`](https://github.com/ntoll/upyed) and Tom Viner's very convenient [`upyflashed`](https://github.com/tomviner/upyflashed). The tool was exiting with a trace in the event of no hex files being available, so I [opened a PR](https://github.com/tomviner/upyflashed/pull/1) 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 ;) ---- The Micro:bit gets a warm Christmas welcome by some of the other flashing LEDs in our house. ![xmas_microbit](http://i.giphy.com/26tP0oYwIJ184Kf4Y.gif) ---- # 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](https://github.com/Geekfish/microbit-week/) for the rest of the Micro:bit projects and [this is the code for the dice roller](https://github.com/Geekfish/microbit-week/blob/master/dicer_roller.py). ![dice roller](http://i.giphy.com/d2Z6C1b3VckTDHpe.gif) I just realised this is very similar to what Martin O'Hanlon did with his [8-ball shuffle](http://www.stuffaboutcode.com/2015/11/microbit-magic-8-ball-with-micropython.html), 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. ---- # 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: ![snowflakes](http://i.giphy.com/d2ZjJTBfZ2WMQuyI.gif) and [here's the code](https://github.com/Geekfish/microbit-week/blob/master/snowflakes.py). ---- # 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](https://github.com/Geekfish/microbit-week/blob/master/happy_plant.py)) 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!): ![happy plant maybe](http://i.giphy.com/26tPmvQGLAWMIOMr6.gif) 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 ---- # Bye Mei-Xiu! I'm packing Mei-Xiu today to send to its next host, [Päivi Suomela](https://twitter.com/peconias). I'm really looking forward to seeing her next adventures :) **Follow the rest of her trip on the [microworld tour website](http://microworldtour.github.io/microbit/meixiu.html)!**