Voting using the Micro:bit
Now, let us make an application involving more than two Micro:bits. We can create an electronic voting machine using multiple Micro:bits. One Micro:bit is used to collect the votes and others are used to cast their votes. Only one Micro:bit will be used to receive the radio messages, while all others will be used to send the radio message. The codes for the two categories of Micro:bits will be different. The code for sending the vote from a Micro:bit is as follows:
from microbit import * import radio radio.on() my_vote = "Vote" while True: if button_a.was_pressed(): my_vote = "Yes" display.show(Image.YES) radio.send(my_vote) elif button_b.was_pressed(): my_vote = "No" ...