BIRS Lab 2: Robot Brain

Step 1: Getting Started

This was our first time working with the micro:bit. To start off, we went on the online Microsoft simulator <www.makecode.microbit.org> and downloaded the original source code. It was pretty easy to figure out, and we found the first easter egg which was a game of Snake, pretty quickly.

Step 2: Simple Sequential and Looping Displays

After familiarizing ourselves with the basics of micro:bit, we used the simulator to program a simple sequence. When we shake it to start, it displayed a message that said “Hello!” and then a flashing pattern of a box getting smaller. We came up with this sequence by playing around with the Basic and Leds sections. It was helpful to have the virtual micro:bit display because we could test out the different patterns and shapes before finalizing the code and uploading it onto our actual micro:bit.

Step 3: Programming the Brain

This part was really fun because we were able to get really creative with what loops and sequences we wanted to put together.  We decided to have a sequence of icons display when button A is pressed, and numbers displayed in a loop when button B is pressed. On the first try, we did fail, because button A worked but when button B was pressed it only displayed a 0. It turns out, we used the wrong function.

We replace the while loop with a for loop and then it worked perfectly. When button A was pressed it displayed a series of icons (heart, smiley face, person) and then stopped after one iteration. When button B was pressed, it displayed a continuous loop of the numbers 1 and 2, one after the other.

Step 4: Using the Sensors

This was a little tricky because we weren’t sure where all the sensors were on the micro:bit, but we decided to use brightness as our independent variable. When the surroundings are bright, the micro:bit would play a sound, and stop when it’s dark. This was harder to pull off because we couldn’t control the brightness in the classroom, but in the end, the code worked.

Step 5: Creating A Basic Animal Behavior System

Our initial idea was to create a game mimicking the behaviors of chickens. One of the LED dots would represent a chicken and move along the grid, one would be a fox chasing it, and one would represent corn which the chicken would move towards to eat it. However, it was difficult to achieve because the LED dots only lit up in one color, so it would be confusing to know which dot represents what. So, we changed our idea to fish behavior, inspired by a scene in Finding Nemo where the little girl shakes Nemo in a plastic bag. Basically, at the start, a fish will appear and a message saying “Hello I’m Nemo” will display. Then, if one presses button A, it will feed the fish and a heart will appear accompanied by a positive sound. However, if one shakes the micro:bit, a sad face will display accompanied with a negative sound because one should not shake fish.

Leave a Reply