# Binary Calculator With Micro:bit

3,788

37

0

## Introduction: Binary Calculator With Micro:bit

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.

## 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

## Step 1: Build Your Circuit

• 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!

## Step 2: Add 7 Segment Display

• 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.

## Step 3: Attach 7 Segment Display

• 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!)

• 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! :)

## Step 5: Load the Code

• 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.

## Step 6: Test It Out!

• 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.

## Step 7: Take It Futher

• 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.

4 454
368 45K
103 9.4K
173 12K