Microbits Workshop
Chicago CSTA workshop at Lane Tech, 5/30/2017
CSPd week workshop July 2017 in Golden, CO
See also the Fall 2017 micro:bits workshop offered by Dan Law and Jeff Solin.
This page at bit.ly/cs4hs2017
Thanks to Google's CS4HS program (and the organizing abilities of UIC's Mitch Theys) for paying for the microbits and other pieces of equipment for us!
A micro:bit is a small device about half the size of a credit card that can be easily programmed to use its built-in LEDs, buttons, motion (accelerometer), a compass, temperature, light levels, and radio signals. It was developed through funding by the BBC and distributed in 2016 to all 5th grade students in England.
[Click on the image below to enlarge it.]
Get a micro:bit card and a micro USB cable, and hook it up to your computer. The microbit box includes a very short usb cable
Point your browser to microbit.org/code and then select the "Let's Code" button:
Within the resulting browser window make a simple application:
Find and place the blocks on the screen, similar to blocks programming you may have done with Scratch or AppInventor.
Select the download button, and find the resulting file in your downloads directory.
Drag the resulting file onto the USB device that represents your micro:bit. The light will start flashing on it while it downloads, and then the program will start running.
Look around the blocks to see what is available. Note that selecting some of the categories also makes a related Advanced option appear for that category.
We will use it as a tool in sending messages to try and figure out who your partner is, somewhere else in the room. We will start with an easy version, and get progressively more challenging.
Now that you've gotten a basic program to work, change your program to be the following. (Note that the bottom show string block uses receivedString. This can be found in the Variables tab on the left.)
Review Question 1: Are you able to send and receive messages? Whose messages are you getting?
Find a group next to you, and together, choose a number in the 0 to 127 range (besides the default value of 1) to use in the radio set group block. Change what is in the radio send string block, download it onto your microbit and send the message by pressing the A button.
Review Question 2: What is the effect of changing the radio set group block number?
Once you get the above to work, change the radio set group block to be a number that we gave you. Your goal is to find the other group in the room with the same number, using only the messages sent and received using your micro:bit. You can change the blocks as you see fit to help you in your goal.
Now that you've found your partner group from somewhere else in the room using your shared assigned number, make a plan together on how to solve this next stage.
Use radio set group to set your group number to 255. This will be shared among everyone in the class, however you should figure out how to display only the messages intended for you and your partner. Explore and experiment with the options in the Radio drawer to find a solution. You may find it helpful to look at the Advanced tab Text options.
Note also that some of the tabs have the "regular" options, but then once selected have additional "...More" options below:
Hint: Think about sending not just a message, but a message and a number. Can you use that number to filter out the unwanted messages?
Congratulations on getting to the extra credit! What if you wanted to communicate with another group, but didn't know what their group number was? To simulate this create a variable to store the radio group, set this variable to some random number between 1..255, and then use that variable to set the radio group:
If both of you do this, how might you still communicate? You should be able to not only see the sent message, but also find out what the sending radio group was. Together with your partner group make a plan and implement it, revising as necessary.
Create a cup critter that uses a servo motor to create some kind of animation in response to some sensor input (light, motion, temperature, orientation, button input). Below is one example (a variation of the Milk Carton Monster) along with the steps to make it, but feel free to make some different device that includes input and use of the servo.
Start with the following supplies:
A couple of stiff waxed paper cups
Microbit and micro usb power cable, to hook up to your computer
A micro servo 9g SG90, ($12.38 for a pack of 5 on Amazon) to do the animation
Alligator clips, which will have one end cut off, to use to connect the servo wires to the microbit. Though not pictured, you will also need three small pieces of electrical tape
A straw and a paper clip to connect the servo to the moving part
A hole punch (and/or scissors) to make the holes in the cups for the hinge
A stiff round cookie stick for the hinge
A glue gun, to fasten the moving part to the hinge and to strengthen hinge joints
Before you get going, take a moment to find a partner. This should be someone seated next to you with whom you can share opinions and get help. Introduce yourselves and tell each other how experienced you are in working on this sort of project. [And yes, this will be on the exam!] With your partner retrieve the above supplies. You will likely need to share some of the items such as paper punch, glue gun and scissors.
After you have found a partner and you have each gotten your supplies, line up the cups and mark the spots for the hinge holes to be made with the paper punch. Keep in mind that the hinge stick will need to go straight through the holes, and consider how the cup will move and whether or not it will hit the front/back of the other cup.
Use the paper punch to make the holes for the hinge stick and insert the hinge stick through the holes, leaving some sticking out on either end.
Carefully bend one end of the stick at a 90 degree angle, so it is parallel to the table top. If you want you can also bend the opposite end of the stick upwards. Bending these sticks will cause them to break part way through. After positioning them where you want them to be, strengthen each joint with a spot of hot glue. Also glue the top cup (but not the bottom one!) to the hinge stick. Once this is done moving the hinge stick should also move the top cup.
Cut a rectangular opening in the side of the cup into which the servo will be wedged. To do this trace a rectangle equal to the size of the back of the servo onto the lower cup immediately below the end of the hinge arm. Make the opening slightly smaller than you need. Tightly wedge the servo into the opening, making sure the wires are accessible.
Attach alligator clips to the end of each servo wire as follows:
Cut off the adapter at the end of the three brown/red/orange servo wires. Carefully strip each of the three wires, and individually twist the resulting stripped ends.
Similarly use a couple of alligator clip wires, cutting them in half and again stripping and individually twisting those ends.
Carefully attach an alligator clip wire to each of the three servo wires, tightly twisting the stripped ends together. Tightly roll a small piece of electrical tape around each of the resulting three wires.
Attach the alligator clips to the microbit. (Careful, you could burn out an electrical component if you connect them wrong!) Attach them as follows:
- Black to GND (ground for the servo)
- Yellow to 0 (data for the servo)
- Red to 3v (power for the servo)
Sometimes the servo motor doesn't work reliably because it is operating at the bottom end of its voltage range. If this is an issue for you then hook up the power directly to the servo, rather than the server taking power from the microbit. To do this you would hook up three or four 1.5 volt batteries (giving 4.5 or 6 volts) directly to the black (-) wire and the red (+) wire, rather than connecting those two wires to the microbit. [Thanks to Dan Law for this suggestion!]
Select the straight arm to be pressed onto the servo motor. Place it on the servo but do not screw it in, as you will need to reposition it later. Create and download the following microbit program so that the motor moves some amount each time button A is pressed, and returns to the original position once button B is pressed.
The pin values should vary from 0 to 180. Experiment with the values and with repositioning the servo arm (by taking it off, rotating it and pressing it on again) until it roughly matches the range of angles of the hinge arm as the hinge arm moves. Do this experimentation without connecting the servo arm to the hinge arm, which will be done in the next step.
Cut off one end of the straw so that it is about the length of the small servo arm. Slide the straw over the end of the arm and push a paperclip through the straw, through one of the small holes in the small arm, and out the other side, pinning the straw in place. Then bend the end upwards towards the hinge arm and bend it again at the hinge arm. Cut it to fit, and slide it over the hinge arm.
Verify it is working correctly with it all hooked up. After testing and adjusting, if necessary hot glue the straw to the hinge arm.
Change the program to use some sensor inputs rather than buttons A and B.
Personalize your critter!
Other microbit projects:
Hack Your Headphones (use your headphones or a small piezo speaker)
Here in the US Adafruit just started carrying Microbits, though at the time of this writing they only have the Micro:bit Go Bundle ($16.50 + $7.40 shipping) and right-angle breadboard edge connectors ($3.95). Bulk orders can get free shipping.
For a much wider range of microbit add-ons, see the Kiktronic microbit site, which does require shipping from England. They have an Inventor's Kit, Line-following Buggy, E-Textiles kit