LED Binary Calculator

35,591

96

63

Posted in TechnologyLeds

Introduction: LED Binary Calculator

About: Electronics and LEDs what can be better ?! :D
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!

Share

    Recommendations

    • Spotless Contest

      Spotless Contest
    • Microcontroller Contest

      Microcontroller Contest
    • Space Challenge

      Space Challenge
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    63 Comments

    Generally, it doesn't matter. You may use text editors like Leafpad, notepad, emacs, vi, ed or even the cat command. You may also use an IDE.

    It really doesn't matter...

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

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

    Hi!

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

    (DEL ALL, ?) thanks for your answers

    Can i contact u via email??

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

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

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

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

    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: http://www.kpsec.freeuk.com/components/led.htm#series 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!)

    1 reply

    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.

    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?

    Thanks

    2 replies

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

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

    Which switches in the wiring diagram connect to the transistors?

    1 reply

    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.

    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.

    1 reply

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