Example Code for micro:bit-MakeCode-Voting Machine

voting machine utilizes the wireless communication function. The voting machine has hosting post and voting port. The voting port can have abundant devices. When the voter presses the related button, the number of the votes will be displayed on the screen. Meanwhile, the data will be sent to IoT platform.

Hardware Preparation

  • micro:bit board (hosting post): Quantity 1
  • micro:bit board (voting port): Quantity multiple
  • Micro: IoT expansion board: Quantity multiple
  • DFRobot Easy IoT platform access: Quantity 1

Software Preparation

Wiring Diagram

Plug each micro:bit board into a Micro: IoT expansion board.

Other Preparation Work

  1. Open the Easy IoT website:http://iot.dfrobot.com.cn/
  2. Sign up/Sign in to Easy IoT.
  3. Add new devices to match each micro:bit, get the device topics.

Sample Code

Makecode programs: voting machine-hosting

Makecode programs: voting machine-voting

Result

Press down button A, send a message to topic0 and change A by 1; press down B, send a message to topic1 and change B by 1.

Was this article helpful?

TOP