ADVENTSKALENDER ADVENTSKALENDER FÜR FÜR MICRO:BIT MICRO:BIT ER MICRO:BIT ERFÜR FÜR MICRO:BIT ADVENT ADVENT CALENDAR CALENDAR FOR FOR MICRO:BIT MICRO:BIT R FOR AR FORMICRO:BIT MICRO:BIT 24 Experimente, die Spaß machen 24 thrilling experiments
Overview of all experiments micro:bit-Advent Calendar 2019. . . . . . . . . . . . . . . . . . . . . . . . . . 3 1. Day . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Today in the Advent Calendar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Preparing the micro:bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
micro:bit-Advent Calendar 2019 The micro:bit is an experimental board and very easy to code. Though originally developed for use in schools, it can be utilized in many other experiments and games. Obviously, the micro:bit is not the first programmable board. Just a few years ago, the microcontroller and single-board computer programming was a task for engineers. However, the well-known Raspberry Pi and Arduino boards made this technology accessible for everyone.
Day 1 1. Day Today in the Advent Calendar • Alligator clip cable Alligator clip cable You can employ these cables as sensor contact points using coins, spoons or other metal objects. Attach one alligator clip to the object and the other to one of the five contact surfaces with the holes on the micro:bit. But be careful not to cause a short circuit with one of the adjacent small contacts. Preferably, stick one side of the alligator clip through the hole in the board.
Top left you see the micro:bit that will play the program. This simulator will also show instantly any changes made to the program at any time, so you don’t have to transfer the program to your "real" micro:bit. The square symbol is used to stop the simulator and the triangle to start it again. The available code blocks in the Makecode Editor are arranged in groups. When you drag a block from the block palette into the workspace, it will first appear gray.
Should the program not respond to the simple sensor touch, touch simultaneously the GND contact at the very right on the micro:bit. Copying the program onto the micro:bit In order to play the program not only on the simulator, but in real on the micro:bit, give it a name in the box at the bottom and then click on the large button Download. Save the downloaded file directly to the MICROBIT drive. The micro:bit should be connected to the computer via the USB cable, of course.
Day 2 Today in the Advent Calendar • Alligator clip cable Merry Christmas Components needed: 1x micro:bit, 2x alligator clip cables Attach one alligator clip cable to contact 0 on the micro:bit and the other to the GND contact. Attach coins, metal spoons or other conductive objects to the other ends. The two sensor contacts will make sure that the program responds even though grounding is weak, if both sensors are touched simultaneously. The program Program microbit-02.
Day 3 3. Day Today in the Advent Calendar • 2x wire electrodes Numeral dice with bananas or apples Components needed: 1x micro:bit, 2x alligator clip cables, 2x wire electrodes With the wire electrodes you can use bananas, apples or similar objects as sensor contacts. Stick one electrode into a fruit and connect an alligator clip cable to it. The program There are many games that use dice but every so often there are no dice at hand. The program microbit-03.
Day 4 Today in the Advent Calendar • Modelling clay Modelling clay is perfect for forming sensor contacts because they are as conductive as human skin. However, a piece of modelling clay has a larger more handy contact surface than a wire. Consequently, you won’t lose connection easily when you touch it. Insert the alligator clip of each of the two cables into one piece of dough and fix the other ends to the 0 and GND pins on the micro:bit.
The program has six different if ... then ...-queries in the Logic Group. Blocks within the brackets of this query are executed whenever the query condition is true. All of these queries use the block ... = ... from the Logic group to check whether the value of the variable dice matches one of the six possible numbers. If this is the case, the corresponding die pattern is shown on the LED matrix. To do this we use the block show LEDs from the Basics group.
Day 5 Today in the Advent Calendar • Lead wire Today our Advent Calendar presents us a lead wire. We are going to use it later on to build different wire connections between components. Game of skill Bend the lead wire to form rings of different shapes. But first you need to remove the insulation with a sharp knife. Then attach a wire electrode to each of the two alligator clip cables. Now try transfer the wire rings from one electrode to the other so that you briefly touch both.
Day 6 6. Day Today in the Advent Calendar • red LED with series resistor LEDs Circuit diagram of a LED with series resistor. LEDs (light-emitting diodes) glow, if current flows through in current flow direction. LEDs are illustrated in circuit diagrams with an arrowshaped triangle symbol indicating the flow direction from the positive terminal to the negative terminal or to the ground wire.
Day 7 7. Day Today in the Advent Calendar • Breadboard (SYB 46) Breadboard The breadboard in the Advent calendar helps us to quickly build an electronic circuit without having to solder. Electronic components can be plugged directly into the holes of the breadboard. On our breadboard, the outer horizontal rows of contact points (X and Y) are all connected. These rows of contact points serve often as the plus and minus terminals to power the circuits.
Day 8 8. Day Today in the Advent Calendar • Alligator clip cable LED flashes on touch Components needed: 1x micro:bit, 1x breadboard, 3x alligator clip cables, 1x red red LED, 2x bare jumper wires, 1x lead wire, 2x modelling clay In order to make contact to ground, the clay sensor needs a longer lead wire that connects to the ground strip on the breadboard. You only need to strip off 1 cm insulation on both ends. The program The program microbit-08.hex causes the LED to blink 10 times on contact.
Day 9 9. Day Today in the Advent Calendar • green LED with series resistor LEDs toggled with a button Components needed: 1x micro:bit, 1x breadboard, 3x alligator clip cables, 1x red LED, 1x green LED, 3x blank jumper wires The program The program microbit-09.hex switches one of the two LEDs on and the other off and vice versa when button A is pressed.
Day 10 10. Day Today in the Advent Calendar • Alligator clip cable Mobile earth ground resistance tester Components needed: 1x micro:bit, 1x breadboard, 4x alligator clip cables, 1x red LED, 1x green LED, 3x bare jumper wires, 1x lead wire, 2x modelling clay Connection to the earth is not always good.
Day 11 Today in the Advent Calendar • Yellow LED with series resistor Traffic signal with pedestrian lights switched by button Components needed: 1x micro:bit, 1x breadboard, 4x alligator clip cables, 1x red LED, 1x yellow LED , 1x green LED, 4x jumper wire blank By means of three LEDs, a simple traffic signal with pedestrian lights will be shown on the LED matrix of the micro: bit. During the traffic signal’s red phase, the pedestrian symbol will change on the LED matrix.
Day 12 12. Day Today in the Advent Calendar • Button Button You can also connect external buttons to pins P0, P1 and P2 and use them in addition to the buttons permanently installed on the micro: bit. The Advent Calendar today has a button, which you can put straight onto the breadboard. The button has four connection pins. The two legs facing each other at the larger distance are interconnected. All four legs are connected as long as the button is pressed.
Day 13 Today in the Advent Calendar • 15 kΩ potentiometer Potentiometer Today’s Advent Calendar potentiometer is a resistor that you can set to values between 0 Ω and 15 kΩ by turning the knob. Analogue level indicator on LED matrix Components needed: 1x micro:bit, 1x breadboard, 3x alligator clips wire, 1x potentiometer, 3x bare jumper wires The three pins P0, P1 and P2 will also read analogue input values.
Day 14 14. Day Today in the Advent Calendar • Resistor 10 kΩ (brown – black – orange) Resistors and their colour coding Resistors are used for example as current limiter for sensitive electronic components or as series resistors for LEDs. Resistance is measured in ohm. 1,000 ohms are one kilo ohm, in short kΩ. 1,000 kilo ohms are one mega ohm, or MΩ. Most often the omega symbol Ω is used to express ohm.
The program The program microbit-14.hex shows the analogue input value at pin P0 as bar graph on the LED matrix. The program is similar to the program of yesterday. If you press the button, the displayed value changes from 0 to full scale, which is approximately 1023. When you remove the resistor, the bar graph won’t even reach the 0 value on the graph, if the button is pressed.
Day 15 15. Day Today in the Advent Calendar • Alligator clip cable Alternating flashing light with adjustable speed Components needed: 1x micro:bit, 1x breadboard, 5x alligator clip cables, 1x p, 1x red LED, 1x yellow LED, 6x bare jumper wires The program The program microbit-14.hex causes two LEDs to flash alternately. The flashing rate is set with the potentiometer.
Day 16 Today in the Advent Calendar • Blue LED with series resistor Flashing colour pattern with four LEDs Components needed: 1x micro:bit, 1x breadboard, 3x alligator clip cables, 1x potentiometer, 1x red LED, 1x yellow LED, 1x green LED, 1x blue LED , 3x bare jumper wires Theoretically, you would only be able to connect three LEDs to the connection pins P0, P1 and P2 and have them flash alternating.
Day 17 17. Day Today in the Advent Calendar • Blue modelling clay Quick response game Components needed: 1x micro:bit, 1x breadboard, 4x alligator clip cables, 4x modelling clay The program The program microbit-17.hex is a game that requires a quick response from the two players. The one, who touches the sensor contact first, when the heart lights up, scores a point. The one who scores five points has won the game. Each player has a clay contact as sensor.
After the symbols are flashing, we need to create the moment where points can be made through touching the sensor contact. To do this, the game variable is set to true and the heart symbol is shown. After a one second waiting interval, the game variable is reset to false. If during this second of time neither of the two players has touched the sensor contact, no point will be awarded in this round and the next round begins. Points are always awarded whenever a player touches a sensor contact.
Day 18 18. Day Today in the Advent Calendar • 15-kΩ potentiometer Game programming with sprites Components needed: 1x micro:bit, 1x breadboard, 4x alligator clip cables, 2x potentiometers, 6x bare jumper wires The breadboard contact strip in the upper part of the figure is used to connect the two potentiometers to +3 V, the contact strip at the bottom is the GND connection. The program The program microbit-18.hex is a simple game.
How does the program work In each of the loops of the infinite loop, two random x and y coordinates are generated, and there the target sprite that the player is supposed to catch. To do this, we use Block create sprite at position x ... y ... from the game group. You find this group in the block list groups under Advanced. A sprite is stored in a variable, which is used to move it around later on. A sprite variable is automatically created when the first sprite block is used.
Day 19 19. Day Today in the Advent Calendar • 2x wire electrodes Water level sensor In this experiment we are going to use the wire electrodes to build a sensor that will indicate the level of liquid in a glass. The electrodes are suspended from a bridge over the glass. You can fold the bridge out of the cut out stencil on the back of the Advent Calendar. Attach three wire electrodes with the alligator clip cables in such a way that the wires are suspended in the glass at different depths.
How does the program work The water variable is initially set to 0 at the beginning of each run in the forever loop and then revaluated and adjusted according to the electrodes’ different immersion depths in the glass. The three electrodes are queried one after the other at the pins P0, P1 and P2. If the electrode is immersed in water at pin P0, it has ground connection. The pin is recognized as being pressed. At this time, the glass with water is at least one third full. The water variable is set to 33.
Day 20 20. Day Today in the Advent Calendar • Phototransistor Phototransistor A phototransistor is a device sensitive to light and looks at first glance like a transparent LED. Depending on the light leaks, the illustrated circuit can achieve different values at an analogue input. The brighter the light that falls on the phototransistor, the lower the value at the analogue input. Unlike LEDs, a phototransistor’s long leg must be connected to ground and not the short leg.
The second program The program microbit-20-02.hex uses an externally connected phototransistor. Depending on the level of brightness, the phototransistor delivers an analogue value between 0 and 1023, which in this case is higher the less light falls on the phototransistor. How does the second program work The program reads the analog value at pin P1 and turns on the LED at pin P0, if the value is greater than 100.
Day 21 21. Day Today in the Advent Calendar • 15-kΩ potentiometer Running light on the LED matrix Components needed: 1x micro:bit, 1x breadboard, 5x alligator clip cable, 3x potentiometer, 9x jumper wire (5 of them bare) The program The program microbit-21.hex generates different running light effects on the LED matrix depending on the potentiometer settings. How does the program work The analogue values of the three potentiometers are read at the start of the forever loop run.
After the last LED at the end of the run we have again a short waiting interval. Then the screen contents are cleared, and the next run starts.
Day 22 22. Day Today in the Advent Calendar • Orange LED with series resistor Guess the number Components needed: 1x micro:bit, 1x breadboard, 5x alligator clip cables, 1x potentiometer, 1x blue LED, 1x orange LED, 6x bare jumper wires The program The program microbit-22.hex is a simple guessing game. The player has to guess a randomly generated number in as few steps as possible. The numbers are displayed on the LED matrix whereby a varied number of dots are used and entered via the potentiometer.
• y – y- value for the coordinates on the LED matrix to display the set number • number stores the number, which the player sets and guesses • counter stores the number of guesses At program start , a secret number between 0 and 25 is randomly selected and stored in the Secret variable. The counter is set to 0 and the end variable is set to false. As long as the end variable is not true yet, the value of the potentiometer is queried whether a guess was placed. The Distribute ...
Day 23 23. Day Today in the Advent Calendar purple LED with series resistor Space Invaders Components needed: 1x micro:bit, 1x breadboard, 3x alligator clip cables, 1x purple LED, 1x orange LED, 3x bare jumper wires The program The program microbit-23.hex is a simplified variant of the computer game classics Space Invaders on our LED matrix of the micro:bit. Rules of the game: • Two enemy ships each the size of two LEDs will drop down from above at random positions.
Likewise, the player ship moves to the right, if button B is pressed. The player ship should fire, if the two buttons A and B are pressed simultaneously. The fire trail should travel very fast from the bottom to the top and then glow in its entire length for a short time. First, the current position of the player ship is stored in the fire variable to prevent any error in the case the player ship moves during the launch.
Day 24 Today in the Advent Calendar • Blink LED with series resistor As a special Christmas treat the Advent Calendar today surprises us with an LED that flashes automatically without a program needed. This kind of LED is used for optical signals in situations where it is important to attract special attention. Christmas quiz Components needed: 1x micro:bit, 1x breadboard, 4x alligator clip cables, 1x red LED, 1x green LED, 1x blink LED, 4x bare jumper wires The program The program microbit-24.
• test list – Text used for the questions • Guess – Logic value, used for the player’s answer • Number – Number of questions Upon start, a text list with the ten questions and a list with the ten logic values used for the answers are created following the same order. The block array length ... from the arrays group calculates the length of the list with the answers and stores them in the number variable, which is used as a loop counter. You can thus easily add additional questions to the game.