Binary Calculator With Micro:bit

by BrownDogGadgets in Circuits > Gadgets

5310 Views, 40 Favorites, 0 Comments

Binary Calculator With Micro:bit

Binary Calculator-0250.jpg
Binary Calculator-0258.jpg

We used a micro:bit with a Crazy Circuits Bit Board and some LEGO pieces to build a Binary Calculator with a 4 bit register. It's a great way to learn how binary works and how to calculate a decimal number from a binary number.

If you like our projects and want to see more of what we get up to each week please follow us on Instagram, Twitter, Facebook, and YouTube.

Supplies

Brown Dog Gadgets does in fact sell kits and supplies, but you don't need to buy anything from us to make this project. Though if you do it does help support us in creating new projects and teacher resources.

Electronics:

Other Supplies:

  • 1 x LEGO Baseplate
  • Misc LEGO Parts

Build Your Circuit

Step Switches and Buttons.png
Binary Calculator-0257.jpg
  • We're going to build our circuit on a large LEGO baseplate. We'll need enough room for the Bit Board, 4 switches, one button, and the 7 Segment Display.
  • Connect the four switches and the button as shown. Each needs to be connected to ground (GND) and to the appropriate pin.
  • The PDF for this guide contains a lot of useful information about how binary works. Don't forget to check it out!

Add 7 Segment Display

Step 7 Segment Display.png
Binary Calculator-0254.jpg
Step All Connections.png
  • Using Female/Female jumper wires connect the 7 Segment Display to the pins on the back of the Bit Board.
  • You can use whatever wire colors you like, but typically we try to use red for positive, black or green for negative (ground) and colors like orange, yellow, blue, brown, etc. for "signal" wires.

  • You can position the components closer or farther apart, as long as you have space to run the Maker Tape to make all the connections.

  • Make sure each path of tape from a component to the Bit Board does not cross over another path. That would cause a short circuit!

  • Remember, Maker Tape is conductive on both sides, so if you cut a piece too short you can just stick another piece on top of it to continue your circuit.

Attach 7 Segment Display

Binary Calculator-0255.jpg
Binary Calculator-0261.jpg
  • Sometimes we build up a LEGO contraption to hold things like our 7 Segment Display, and sometimes we design and 3D print something... but sometimes simple is best, and some tape or a well placed rubber band does the job.
  • For this project we just built up a small wall of LEGO bricks and mounted our sensor to it using a rubber band. (It works!)

Add Labels

Binary Calculator-0250A.jpg
Step Labels.png
  • This step is completely optional, but sometimes labels are helpful.
  • Is the first switch 8 or is it 1? Is the switch on when it's up or down? With a few labels you won't have to remember! :)

Load the Code

Code Framed.png
  • Connect a USB cable to the micro:bit and then plug it into your computer.
  • We'll be using makecode.microbit.org to program our board. It uses a simple drag and drop block interface.

  • We're going to load the following code for our Binary Calculator program: https://makecode.microbit.org/_avbceA0oHcob

  • The attached PDF for this guide goes into great details explaining the code and what each section does.

Test It Out!

Step Test.jpg

  • Once you've got the code loaded on the micro:bit you can test it out.
  • For this project you can either power the Bit Board using a 2 AAA battery pack, or by keeping the USB cable plugged directly into the micro:bit

  • Can you step through the sequence to count from 0 to 15 by selecting the position of each switch and pressing the Calculate button? Challenge your friends to see who can do it faster, or who can do it without making any mistakes.

Take It Futher

Binary System.png

  • This binary calculator has a 4 bit register and counts to 15. How high could you count with a 16 bit register? How about a 32 bit register?
  • The attached PDF has a good explanation of bits and how binary systems work, including a handy chart you can use to visualize how to set the switches to get the desired decimal.