element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
microbit
  • Learn
  • Learning Center
  • STEM Academy
  • microbit
  • More
  • Cancel
microbit
micro:bit Blog Voting Project
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join microbit to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: rancell
  • Date Created: 2 Nov 2018 8:51 PM Date Created
  • Views 1338 views
  • Likes 5 likes
  • Comments 1 comment
  • micro:bit education giveaway
  • stem projects
  • the great micro:bit challenge
Related
Recommended

Voting Project

rancell
rancell
2 Nov 2018

About this project

 

In this project we'll use micro:bits to make a voting system. Have you ever watched a game show on TV where you "ask the audience" for their answer? We can make the same with micro:bits. To do this project you should have some experience with basic micro:bit programming and using the radio.

 

Let's start with a design:

  • Every voter will have their own micro:bit.
  • One person will start the vote by saying what the vote is for and pressing A+B.
  • There will be 10 seconds to vote and this will be shown as a countdown on the LEDs on the micro:bit who called the vote.
  • Each person will be prompted to vote with a question mark on their LEDs. They can vote yes by pressing A and no by pressing B.
  • Once selected your vote is final!
  • When the 10 seconds is up the result will be shown on the LEDs on the micro:bit who called the vote.
  • The result is either yes (more yes votes than no votes), no (more no votes than yes votes) or a draw (the same of both).

 

We'll need a number of variables to implement this:

  • 'state' - this will record what state the micro:bit is in. It can be one of:
    • 'idle' - the micro:bit is not doing anything.
    • 'calling_vote' - the micro:bit has called a vote and is waiting for results.
    • 'voting' - the micro:bit is a voter and is waiting for the user to choose yes or no
  • 'yes_count' - the number of yes votes received.
  • 'no_count' - the number of no votes received.
  • 'countdown' - the number of seconds remaining until voting is complete.

 

We'll use the following strings to send as radio messages:

  • 'vote' - Sent from the micro:bit that is calling the vote. Causes the other micro:bits to vote.
  • 'yes' - Sent from the voting micro:bits. The user voted yes.
  • 'no' - Sent from the voting micro:bits. The user voted no.

 

Make sense? Let's code!

 

What you'll need

 

3 x BBC micro:bit (or more if you have them)

1 x Micro USB

1 x Computer or tablet

6 x AAA Batteries & 3 x Battery Holders (optional)

 

Project walk through

 

  • We need to start by choosing a radio group. Choose a group number that no-one else in the room is using, in this example we've chosen group 1.

 

image

 

  • Next we need to create a variable called 'state'. This will track what state the micro:bit is in. We start in 'idle'.

 

image

 

  • To start a vote we need to change to the 'calling_vote' state when A+B is pressed. We need two make two variables to store the number of yes and no votes received. We also need to tell the other micro:bits to send in their votes. We do this by sending a radio message to them - 'vote'.

 

image

 

  • To give everyone some time we'll wait 10 seconds for the votes to come in. This is done by making a new variable called 'countdown' and decreasing it every second until it gets to zero. We'll display this on the LEDs so you can tell everyone to hurry up and vote!

 

image

 

  • After 10 seconds times up! Let's look at the votes we received and show the result! Either the result is the yes voters win, the no voters win or it's a draw. Once shown let's go back to the 'idle' state for the next vote.

 

image

 

  • Now for the radio receiver. If we receive the 'vote' message and we're not doing anything else let's join in the vote. We change our state to 'voting' and prompt the user with question mark.

 

image

 

  • Vote yes by pressing A. We need to check if we're in the 'voting' state - this means we only vote when we're asked and only once. The vote is shown on the LEDs and sent as a radio message.

 

image

 

  • Vote no by pressing B. This is very similar to the yes code.

 

image

 

  • All that's left to do is count up the votes. Extend the 'on radio received' block to collect these votes.

 

image

 

  • Congratulations, you made it! Now you can get your friends together and vote on something. How about... "Do you love micro:bit?". One person asks the question, presses A+B and then everyone else either presses A for yes, or B for no. The person who started the vote can call out the result: Yes, No or Draw. Time for another vote!

 

Next steps

 

  • Can you show how many people voted for yes and no? Was it a close victory or did everyone agree?
  • Can you make the result show on all the voters LEDs?
  • Can you make a multiple choice vote? i.e. A, B, C, or D?
  • Sign in to reply
Parents
  • genebren
    genebren over 6 years ago

    Fun little project.  This would be cool to see in a debate-like situation, where you could get real-time polls to see how persuasive arguments are.

     

    Gene

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • genebren
    genebren over 6 years ago

    Fun little project.  This would be cool to see in a debate-like situation, where you could get real-time polls to see how persuasive arguments are.

     

    Gene

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube