Introduction: LED Binary Calculator

You can't calculate binary values "as is" on most handheld calculators and using the windows one is just a pain, so i decided to make my very own (binary only) calculator.
This calculator supports all the basic functions like : NOT,OR,AND,XOR, addition,subtraction,multiplication,division and modulo.

So join me as we are going to enter the world of ones and zeros and play with some LEDs and switches along the way!

Step 1: Parts List

Like any electronics project you will need to get some basic tools  like:
a soldering iron, some solder wire, a cutter, a needle nosed plier,some wire, wire striper, and some desoldering tools fro fixing mistakes along the way.

The parts for the calculator:
1. 32 LEDs.
2. 8 resistors( The value is determent by the type of LEDs, in my case 91 ohm).
3. 74HC595 shift register.
4. 9 1KOhm resistors.
5. 4 2n4401 transistors.
6. A Perfboard.
7. ATtiny2313.
8. 16 tact switches with 4 pins.
9. some pin headers.
10. A programmer for the micro.
11. 9V battery holder.
12.A slide switch.
13. 7805 voltage regulator
14. 100nF cap
15. 10uF cap

Step 2: How to Control 16 Inputs and 32 Outouts?

I had an ATtiny2313 micro in my parts bin and I wanted to use it for something, the thing is that it only has 17 outputs minus 2 if you use a crystal, and to control so many outputs and inputs I had to use some tricks to get around using just 15.

The first trick is multiplexing the the LEDs and arranging it in a matrix form, we connect the LEDs in a grid of 8X4 so now we need 12 outputs and not 32 but thats still a lot and we will need to find a way to get that number smaller. So I used a 74HC595 shift register which needs only 3 pins from the micro and gives you 8 outputs, the 74HC595 controls the columns and the micro scans the rows with the help of 4 transistors, and now we can control 32 LEDs with only 7 pins.

The second trick is to multiplex the switches as well and arrange them in a 4X4 matrix, and now we only need 8 pins to read the switches and not 16.

All the logic operations are being made in software so if you know your C you could use any micro-controller with 15 I/Os or more and adapt my code to work with it.

Step 3: Schematics

As always the only thing I left out in the schematics are the resistor values which limit the current to the LEDs, this is a thing every one does by himself.

You can use a special site to calculate the resistor value like this one . Or do it yourself with the help of a simple equation (Vin-Vled)/(Iled).

I recommend downloading the original file with the schematics to see them clearer.

Step 4: Soldering Tips

The two tricky parts in this project is soldering the LEDs and the switches and thats because the connect in a matrix formation.

Soldering the LEDs are a lot easier and the way you need to do this is to bend the positive lead of the LED down towards the other ones and make a column, and snip off the leads you didn't use and make the connections as low as you can get, and you do this to all of the positive leads.
Now the negative leads are connected in a column and thats make soldering tricky because the positive rows are in the way, so you will need to make a 90 degrees bend with the negative lead and make a bridge over the positive row to the next negative lead, and so on to the next LEDs.
Now because there are switches between the LEDs rows you will need to make 8 jumpers for connecting the 8 columns, the jumpers can be made from simple wire with isolation or you can use magnet wire.

The switches gives the biggest headache because they aren't soldered in a grid and thats makes it hard to connect them in a matrix form.I used a method called wire wrapping which uses a very thin isolate wire to connect points on the board. I have also added a wiring digram of the switches.

The controller circuit is simple and every one chooses how to make it so the only words of advise I will give is to bolt down the voltage regulator to the board to protect it from vibration and shock that can cause it to fall off, make a little hole in the board for the battery wire and by so creating a strain relief and the last thing is to add some pin headers for programming the micro unless you want to take out the micro every time you wish to program it.

Step 5: It's Programing Time

This is the last thing to do, to make the calculator run.
I wrote a basic program for it so it can calculate all the needed things, I have the description of what every button does in the picture.

People who know C can easily adapt my code to make it run on the arduino or other platforms it's just a matter of changing the output and input commands. The code is fully documented so you can understand what each line does.
If you're going to use an ATtinty2313 I have added an HEX file as well to save some time. And if your going to use the HEX file remember to set the fuses to use the internal oscillator on 8Mhz.

I used the USBasp to program my micro but you can use any program you like or have at home.

Step 6: Lets Calculate Some Binary Stuff

Congratulations you have made a handheld binary calculator form scratch, and now can do all your favorite math operations in binary :D.

Have fun!


mmayur made it!(author)2016-05-24

hay ...plz told me con i use any another microcontroller....

Mayuresh+Rangole+ made it!(author)2016-02-15

Hello!!! Its truelly great project ...but i have one question that which another microcontroller we can use and what is program for that????

nklanjscek made it!(author)2016-01-09


I do this projct in eagle and i don't know wich pushbutton is where like that

(DEL ALL, ?) thanks for your answers

mamk9 made it!(author)2015-10-17

Can i contact u via email??

AshwinS1 made it!(author)2014-11-05

Can you please make a tutorial to decode the binary and display the numbers on a seven segment display with an IC?

mycolourpurple made it!(author)2013-06-04

plz help me regarding the working ov this calculator .. how it works ? where are the inputs .. which one are outputs ... n how to read it ...???

mycolourpurple made it!(author)2013-06-04

plz help me regarding the working of this calculator ... which are the inputs , which are outputs ..n how to read this ... plz tell me :)

electronicz made it!(author)2013-04-22

What program do you write the code in?

pilotavery made it!(author)2012-01-18

Would you sell it? $30?

Syst3mX made it!(author)2012-01-20

There is nothing left to sell the project was recycled to something else

cosmicr made it!(author)2012-01-10

how come you don't need a resistor per led? they are wired in parallel but there is only one resistor per row?
this article: says it wouldn't work?

also, using 91 ohms and 5v does that mean your led current is 55mA? That seems high to me and using (Vin-Vled)/(Iled) it would mean your led is 0.086V? I'm confused.

But thanks for the great instructable, I'm planning on using these concepts to make a bit led array (as soon as I get my head around it!)

Syst3mX made it!(author)2012-01-12

Because I used the same type of LEDs in this project(they all came from a batch of 1000 LEDs) There is little worry for on LED taking all of the current.

If all of the LEDs are the same the current will divide equally between the 3 LEDs.

But the article is correct generally it's not the best of ideas to use just one resistor but I wanted to save some space and I had the same type of LEDs.

m1s73r made it!(author)2011-11-13

I've got a question:

So, you're using blue LEDs and resistors with 91ohm... But my question is what's the source voltage? Doesn't the voltage regulator lower it to 5V ? Therefore you should use 120ohm resistors - am I right?


Syst3mX made it!(author)2011-11-14

Yep you are correct but my cheap ebay LEDs work like crap with a higher resistance.

m1s73r made it!(author)2011-11-15

Oh ok, hopefully mine work better... I bought 50 LEDs + 50 resistors for just 6,77 $ But anyways, thanks for answering my question!

mwagner63 made it!(author)2011-08-28

Which switches in the wiring diagram connect to the transistors?

Syst3mX made it!(author)2011-08-28

I will update this instructable till the end of this weak, I just not home so I don't have the original project next to me.

mwagner63 made it!(author)2011-08-24

How do you read the answer lines. I'm a noob when it comes to binary as i just started learning it. Also what is LSB and MSB.

Syst3mX made it!(author)2011-08-24

The answer line consists of 2 lines.
In the upper line in first right LED is the LSB ( Least significant bit ) which is like the first number in a digit. Lets say you work with a normal number of 5623 the number 3 will be like the LSB because if you change it that number the change in the overall value wouldn't change that much.
And the 5 is the MSB ( Most significant bit ) if you change that number the overall value will change dramatically.
So in this calculator the bottom left LED is the MSB one.
Now the way you read the answer is like so : the first 8 LEDs are the lower part of the answer and the bottom line is the upper answer.

To make it a bit clearer lets say we have an answer of 1259, The first line would be "59" and the second line would be "12".

mwagner63 made it!(author)2011-08-26

Thanks but I have one more thing. In the schematic you have the switches numbered. Could you help me out by telling me which number switch does what function? I had difficulty understanding the wiring diagram of the switches. Thanks again.

Emiliano+Valencia made it!(author)2011-07-21

hi, I just want to tell you, you could have read all the pushbuttons with only 1 pin, an ADC, you would have to connect all the buttons in a resistor series and Gnd on the other side, that would give you some 7 extra pins

Syst3mX made it!(author)2011-07-22

Yeah I am familiar with that trick, but the problem is the this chip doesn't have a built in ADC.

callain made it!(author)2011-05-27

Is it bad if you replace the 74HC594 by a 74HC795N or a 74HC795D ??
Thanks !

Syst3mX made it!(author)2011-05-27

I have never heard about this kinds but the schematic has it a bit wrong the part is : 74HC595

callain made it!(author)2011-05-27

So is it ok ?

Syst3mX made it!(author)2011-05-27

a 74HC595 is ok the 74HC795 i can't find at all

jensenr30 made it!(author)2011-05-08

VERY NICE soldering work! I greatly respect the work, thought, and effort you have put forth into this project!

sexysaqib made it!(author)2011-05-06

I'm trying to make this calculator, but the schematic you've provided doesn't work when I simulate it in proteus design suite. Can you help?

Teslaling made it!(author)2011-02-01

It's too bad u can't enter this into the Microcontroller contest!

Syst3mX made it!(author)2011-02-01

hhh yeah i was thinking about the same thing when I saw that contest.
I wish I had more free time on my hands to make something

shane11 made it!(author)2011-01-30

OK so im new at circuitry so bear with me i know programming and trying to get started in circuits so where do i make a programmer to put the code on the device and also how much about did the project cost to make thank you.

Syst3mX made it!(author)2011-01-30

Well if you are new to this kind of things I think this kind of project is a bit over your head, I can recommend starting with something simpler like a LED chaser just to get some basic skills.
I used 2 softwares in this project one called "AVR studio" in which I write the program in C and "Khazama AVR programer " that I use to write the program on to the micro itself.

The total cost with the program(which is a 1 time buy) is about 30-40 dollars.

shane11 made it!(author)2011-01-29

IS there a way i can do this without soldering????

Syst3mX made it!(author)2011-01-30

I think you can do it on a breadboard but it will not look nice

menghuei321 made it!(author)2010-10-26

My programmer cannot read the attiny28l chip, can I use pic chip like pic18F4620 to replace the attiny? If can, can I use the same HEX file you have provided?

Syst3mX made it!(author)2010-10-26

Yes you can use any micro you want, the only thing is to look for the same number of I/Os or more.
This HEX file will only work for the micro I used so you will need to compile the code for the micro you use.

menghuei321 made it!(author)2010-10-26

Wanna ask if I use the attiny28, can I still using your HEX file which you have provided?

mathman47 made it!(author)2010-10-23

I always like hardware/firmware that does something completely different and shows how to save pins.Just wish desktop PCs were as flexible as these little & cheap micro-controllers. I paid $289 for my i7-930 and my Arduino was $34.

I wonder why it took 17 days for Instructables to send me an email that this was published? Keep up the good work.

Syst3mX made it!(author)2010-10-24

Thank you sir :)

menghuei321 made it!(author)2010-10-18

seems you have used the pin PD0 to pin PD6 have been used by the led circuits, then why you connect the buttons to pin PD0 to pin PD7 again?? It is pin PB but not PD in the circuit above?

Syst3mX made it!(author)2010-10-19

Ohh right, thank you for telling me.
I will fix it as soon a possible.

menghuei321 made it!(author)2010-10-13

can I use attiny28 to replace attiny2313 ? attiny28 got 28 pins, but attiny2313 got 20 pins.

menghuei321 made it!(author)2010-10-14


Syst3mX made it!(author)2010-10-13

Ahm yes why not

menghuei321 made it!(author)2010-10-13

can i use attiny28 to replace attiny2313 ? Is it the same function for these two micro cips because I found that attiny28 contain 28 pins which have the pin same like attiny2313 but attiny2313 with 20pins.

mertaxoy made it!(author)2010-10-10

hello Syst3mX,
i want to make this binary calculator with an arduino. Can u help me about the schematic and programming ?

Syst3mX made it!(author)2010-10-10

Sure, send me you email in a privet massage and I will help you out.

Syst3mX made it!(author)2010-09-24


nevdull made it!(author)2010-09-11

This instructable is fantastic! I love the compact design and great functionality of this device. You've done great work, sir! 5 stars!

christapher made it!(author)2010-09-06

now there is no use of such calculators but you done a great job its helpfull for student who where doing mini projects

About This Instructable




Bio: Electronics and LEDs what can be better ?! :D
More by Syst3mX:Make a Desktop TamagotchiLED Binary CalculatorMake a 24X6 LED matrix
Add instructable to: