From 12th to 20th of February 2019 with the students from the class I teach we did an activity described below. The duration of the activity was 35-40 minutes.
Students built a program that implements open and closed circuits. As described in the link below:
In this way they learned about the variables as properties of the objects, as well as using messages to communicate between the objects. The on variable determines whether the switch is on or off, and thus the state of the circuit. This exercise aims to make students familiar with the concepts of object-oriented programming. It also aims to help them understand the concepts of physics of the power source, the switch and of the open and closed circuits.
They started with the following program and made the code to complete it.
On further consideration, I think it is a good idea to follow the previous activity with the activity below or vice versa.
The buzzer is connected to the micro:bit and the micro:bit is connected to the power pack or the computer. So a circuit has been made. It goes from the P0 down to the positive terminal of our buzzer and from the buzzer it goes to the ground.
Then the micro:bit is loaded with the following code:
On button A pressed
digital write P0 to 1 * that turns P0 on
On button B pressed
digital write P0 to 0 *that turns P0 off
Therefore by pressing buttons A and B, we have a closed and opened circuit. When it is closed electric current passes through the buzzer and we hear a sound and when it is open no electricity passes from the buzzer and it is silent. An LED could be connected instead of a buzzer.
Vasiliki Servou, at Kareas High School, Athens, Bironas, Greece