Picture of 4 Bit Binary Calculator

If you need to quickly add numbers from 0 to 15, and you know how to rapidly convert to binary and back to decimal, this is for you...But if your human then this is just a fun project!!  I'm going to show you how to make a 4 bit (0-15) adding calculator using 74xx series IC chips.

The chips that I used are the very basic gates like OR, AND, XOR, NOR, NAND, etc.  No actual adding chips are used so its one level up from transistors, and it's totally TLL!**

By the way, this is another addition to the unofficial "Macroelectronics" catagory for all of you who have seen my diy ram instructables!

**If you use the 74hc series or 74hct series, then its technically not TLL, but who cares about the techincal details!!

Remove these adsRemove these ads by Signing Up

Step 1: The Materials

Picture of The Materials

This project only requires a few parts:

1 Breadboard, maybe 2 - It should have atleast 50-60 rows
2 74xx AND chips - I used the 74hc08
2 74xx XOR chips - I used the 74hc86
1 74xx OR chip - I used the 74hc32
1-2 DIP Switches - I used 2 8 switch DIP switches (I'm gonna expand to 8 bits)
8 1K ohm -or greater- resistors
Lots of wire - Don't yell at me but I use bare copper! Its a bad habit, (some may argue that it's a dangerous one) I know, but I don't care!

Step 2: How It Works - Part I

Picture of How It Works - Part I
The basic adding circuit is just that, basic!  It consists of a XOR gate and an AND gate to give you the basic output with a carry bit.

The XOR gate is short for exclusive or.  In a regular OR gate, 0 and 0 equal 0, 1 and 0 equal 1, 1 and 1 equal 1.  In an exclusive or gate, 0 and 0 equal 0, 1 and 0 equal 1, 1 and 1 equal 0.  This is important because when adding 1 and 1 in binary you get 10, so the ones place has a zero, something that can't be done with a basic OR gate.

A  B  Y
0  0  0
1  0  1
0  1  1
1  1  1

A  B  Y
0  0  0
1  0  1
0  1  1
1  1  0

So now, when you add 1 and 0, you get 1, but hold on...When you add 1 and 1, you get 0?? That can't be right! In order to fix that, we need to be able to have 1 and 1 equal 10. Welcome to the AND gate.  As the name implies, an AND gate equals 1 when A=1 AND B=1.  This it tied in parallel with the XOR gate and is the carryout bit, so that when you add 1+1, you CAN get 10!

Step 3: How It Works - Part II

Picture of How It Works - Part II
Ok, so we can add 1 and 1, but what if we want to add 11 and 11, well the problem is that there is no carryin bit on the second adder. We need a full adder. In order to make a full adder, we have to use 2 XOR gates, 2 AND gates and an OR gate. The circuit for the full adder is shown below:

The full adder works by putting inputs A and B through a XOR gate, then taking the output from that and XORing it with the Carry-in.  This gives you the bit output.  To make the Carry-out, you have to put A and B through an AND gate, and put the output of the A XOR B gate and the Carry-in through an AND gate as well. When you put those 2 outputs into an OR gate, you get a Carry-Out bit. So now we can put a bunch of these together and get a calculator.

Step 4: How It Works - Part III

Picture of How It Works - Part III
4 Bit Add.JPG

Now that we have full adders, its time to put them together to make a calculator.  To connect all of the adders together, you have to connect the carry-outs to the carry-ins in a cascading fashion.  So the carry-out of the first adder connects to the carry-in of the second adder and so on.

Below shows the concept.  The blocks represent the adders and the arrows are the carry-ins and carry-outs.

Step 5: Building It On A Breadboard

Picture of Building It On A Breadboard
4 Bit Add.JPG

Ther are a few tricks to building this on a breadboard.  The organization of the chips on the board is very important, I found that putting the chips in this order works well: XOR, AND, OR, AND, XOR, then the DIP switches.

Another good idea is to build each adder one at a time and on one side of the logic gates.  There are 2 XOR and 2 AND gates on each side of the chips so that makes construction a lot easier.  The order that I put the wires on were: connections to the DIP switches, inter-gate connections, and finally connections to the LEDs.

To wire up the switches, you first (this may only apply to cmos versions of the chips, I haven't been able to experiment TTL versions yet) connect the side not connected to the adder inputs to the supply voltage.  Next connect the other side (the pins connected to the adder inputs) to ground through a 1K ohm, or greater, resistor.

The LED's are connected to the outputs of the adders through a 1K ohm resistor.  If you are using the 74LS series or similar (any series that can't source 5 mA or more) you will have to connect the output to a transistor to get to the required current.

Step 6: For Those Who Don't Understand Or Are So-So With Binary

Picture of For Those Who Don't Understand Or Are So-So With Binary
If you understand the phrase "There are 10 kinds of people in the world, those who understand binary and those who don't" go on to the next step! If not, stay here!

The number system we know and love is base 10. This means that each new column of numbers is 10x the last column (if you don't believe me, divide 10 by 10 and you get 1 or divide 100 by 10 and you get 10, these relate to the 100's, 10's, and 1's columns).  Binary, or base 2, is different in that each column is a power of 2 (so each new column is 2x the last) and it uses only 1s and 0s.

Let's look at binary numbers.  Take the number 10 for example. In binary, 10 is 2 in base 10 because the  first column is the 1's column and the second is the 2's column (1*2=2). If we break this number down, we get 1 in the 2's place and 0 in the 1's. 2+0=2, so 10 is 2. Another number example could be 101.  Now we have 3 columns to work with.  In binary this is the 4's column because 1*2=2, in the 2nd column, and 2*2=4 in the 3rd column.  Let's break this down, there is a 4 and a 1 and no 2s.  4+1=5 so 101=5.

Now that you get the basics of binary, we can learn to convert to binary from base 10.  To convert to binary, you have to subtract the power of 2 that it is greater than the number until you reach 0. This may sound confusing, as it is hard to explain without examples, so thats what we are going to do.  Let's take the number 15.  15 is greater than 8 (powers of 2 include 1, 2, 4, 8, 16, 32, etc.) so we do 8-15=7. We also put a 1 in the 8's column. The next power of 2 is 4. 7-4=3, so we put a 1 in the 4's column. Next is 2. 3-2=1, so we put a 1 in the 2's column. And finally 1-1=0, so we put a 1 in the 1's column.  When we put all of these together we get 1111.

Now let's lake the number 11.  11-8=3, so we put a 1 in the 8's column. 3 isn't bigger than 4, so we have to put a 0 in the 4's column. 3-2=1, so we put a 1 in the 2's coulmn. And finally, 1-1=0, so we again put a 1 in the 1's column. This gives us the binary number, 1011.

Step 7: Going Farther And Final Notes

Picture of Going Farther And Final Notes
Now you have a 4 bit adding calculator, congrats!

I know that there are adding chips in the 74 logic family, and that there is a calculator much more sophistocated in my kitchen drawer, but this fun little project helped me, and hopefully you too, learn more about adding numbers with electronics and logic.

I hope to build an 8 bit adder, as a 4 bit adder is wimpy with up to 15+15, along with subtraction too!
1-40 of 55Next »
Csfmwccc2 months ago
Can you add a full circuit schematic for reference.
shiny.safwan3 months ago

Can you just give the 4 bit logic circuit of addition , subtraction and multiplication that if user wants to muliply or add numbers on run time, they can do it just like simple calculator???

nobody.gg7 months ago
Bushra4877 months ago
Can you privide binary subtractor circuit??
Shortcircui8 months ago
so these gates are each quad versions, which means if I wanted to do this completely with discrete components, I would need to make 4 pf each gate per chip, right?
perfect project, no other word
karneek made it!1 year ago

Ok I got it !!!

Screenshot (48).png
nrmhsri karneek11 months ago

did you do this project as it is above given circuit

then how to give inputs and check for outputs

nrmhsri11 months ago

how to check the output

nrmhsri11 months ago

how to check the output

karneek1 year ago

Hey man i want to build this one but I couldn't understand which wire goes where ... so I am asking you for an on board instructions ( what you wired where and to ic which leg ) if you can give a diagram of that 1(2) breadboard ! please ? If you can :) It'll be a great thing for people like me :) thank you :) (Y)

I used another complicated system of using 555 timers and 4017 ICs to convert binary into decimals...

nyo tom1 year ago
how could I connect this to an LCD that would tell me the value instead of LEDs so it would actually read me the sum in binary?
tridecagon1 year ago
I, personally, prefer the 4000 family of ICs for these types of projects over the 7400 family. The 4000 family has a wider operating voltage range of 3(?)V - 15V. And at 9V, the outputs can push enough current to drive LEDs directly (just remember the resistors). And to answer my month old question, yes you can start with a half adder.
tridecagon1 year ago
By "TLL", do you mean "TTL" (Transistor-Transistor Logic)? But I do have one question I think I have the answer to: since we do not have any carry bits in the very first part of the adder, could we start off with a half-adder? I don't see why not, as it would always be low anyways, but I just want to be sure.
jnowak2 years ago
oh ok. gotya.
I have one bit put together right now and i'm pretty sure the schematic matches yours, but I'm having a good deal of trouble and seem to be inducting power into it or something when i bring my hand close or something. I end up with something like:

0 + 0 = 1
0 + 1 = 10
1 + 0 = 10
1 + 1 = 11

any ideas?
jnowak2 years ago
Do you need that OR gate? ether one or the other AND gates has an output so you could just have both the AND's output go right to the carry out, right?
also, if you powered a input with Vcc, would it fry? I'm not quite understanding, but nice job!
Teslaling (author)  jnowak2 years ago
Yes the OR gate is necessary and no powering an input with Vcc won't fry it. Let me explain: The chips use CMOS logic. CMOS has to important properties: 1) inputs are voltage dependent not current dependent (no current flows into or out of the input); 2) outputs source current when high and sink current when low. The first property means that even if you connect an input to Vcc, no current will flow. The second property means that if you have two outputs connected together and one is high and the other is low, then a ton of current will flow from one to the other, frying them both. The solution is to put an OR gate there so that both of the outputs are connected to inputs that do not sink or source current.

I hope this clears things up!
Marat19982 years ago
Where can you actually buy 74hc chips?
Teslaling (author)  Marat19982 years ago
The 74hc chips can be found at various electronics suppliers such as Mouser, Digikey, or Jameco.
uditkotnis2 years ago
May I ask you which battery terminals have you connected to the vcc and gnd points on the chips?
Also I did not understand the way you connected the dip switches.
Sorrry if I sound a little dumb but this is my first electronics project with transistors.
uditkotnis2 years ago
Hey I tried making this project but when I switch on the dips to make inputs the current bypasses the entire circuit.
can you please tell me what is your supply voltage,
I used two 9v batteries in series.
When I dont have a input all the LEDs glow even if all the dip switch keys are open.
Teslaling (author)  uditkotnis2 years ago
I think your supply may be the issue. According to the datasheets, the chips have a maximum supply of 6v. two 9v batteries gives 18v which is way more than enough to fry the chips. This is probably why the LEDs are glowing, the chips are dead. The best thing you can try is replacing all of the chips and lowering your supply voltage. I have a converted computer PSU that gives stable 5v but a 2 or 4 battery pack would work. Just keep your supply below 6v.

Good Luck!
hey i have all the same parts as you except my or gate is a 74LS32 and i cant get it to work when i test it so any trouble shooting or things i need to know when using gates? ps its not a bad gate because i have tried 2 of them now

Teslaling (author)  thatrandomguy803 years ago
I think that might be the problem. 74hc is CMOS logic levels whereas 74ls is TTL logic so there are incompatibilities when interfacing between the two. If you want, you can do a little more research on the issue, but what you need to know for this is that 74ls won't work with 74hc.

I believe that 74hct can work at both CMOS and TTL levels.
techno guy3 years ago
You could make this subtract by putting a signal into the carry-in of the first and unused carry-in input and then inverting your b value. e.g.: 1011=0100. That is how I made the calculator I built in minecraft to be able to also subtract. When you do the subtract thing, the carry-out of the last adder will turn on but will not mean anything, you could put a switch there to turn it off while subtracting.
Macattacku3 years ago
sorry its been awile but a npn transitor would work very well with a 100k resistor on its base and with that combo the data could last maybe ten seconds which is more than enough. i dont quite know quite how to show the the circuit.
Macattacku3 years ago
I dont mean to brag but I happen to have a very wide knowledge of the inner workings of computers, logic gates, and computer arithmatic and data flow and i was wondering I already know how to do it but i dont really have the time. could you make an instructible on making a byte of d-ram memory? if you want to make or have questions please leave a comment to talk to me.
Teslaling (author)  Macattacku3 years ago
Awesome! I actually started some work on that and another project after I published the results of my SRAM project. I've been working on a dram cell and a 555 timer circuit. I developed a fairly reliable long tail differential comparator for both and I'm in the process of simulating the circuits. I don't know if I can do a full byte, but I would be happy to attempt a few bits.
its actually very simple for just one byte just 16 n channel mosfets, 8 small value capacitors 0.1 or 1 uf, and 8 comparators. since there is only one byte it does not need a transistor per cell because that is just for selection. how long the data will last is based on the size of the capacitors and the amount of current drawn into the comparator. so a regular comparator will work fine but a comparator with low input current draw would work the best.
Teslaling (author)  Macattacku3 years ago
Actually, the mosfets have reverse current body diodes in them, so any transistor that will have current going both directions will need two mosfets per gate. (32 total mosfets) I would then need 3 bjts per comparator (2 pnp and an npn). It's going to be large and I don't have the room without ripping up some other circuits I've been working on.

No offense, but why do you want me to make a full byte? Personally, I would think a few bits or a nybble would suffice.
actually it just need to amplify a signal so you could just use an npn transistor with a 1 k resistor on the input no pull up resistor required. but yes a byte is sorta large so how about a nybble? also there is one thing i missed to tell you an OR gate per bit is also required but you can just used two resistors ten k would be ideal.
Teslaling (author)  Macattacku3 years ago
The problem with a single npn is that if 3 bits are 1 and one is 0, there is going to be leakage to that one. If the voltage is high enough to be amplified enough to be a 1 (<.5 volt is needed) With a comparator, however, the threshold could be 2.5v (5v supply) so anything less is a 0 and anything over is a 1. It's a less temperamental solution, and a bit of a personal preference. Besides, real dram uses a comparator, but using an IC just doesn't sit well with the spirit of it, for me at least.

A nybble will definitely work, but if I have the room, I will try a byte too :)
tarantado3 years ago
Teslaling (author)  tarantado3 years ago
3V to 5V should work fine. 2 or 3 AA will do it, or if you can get power from USB that is regulated 5v.
tarantado3 years ago
shane114 years ago
I cant seem to find a XOR GATE with the model number 74HC86 on jemeco thats an OR gate.
Teslaling (author)  shane114 years ago
Are you sure? 74HC86N - Quad 2 Input Exclusive OR Gate??
oooo whoops sorry bout that!!!!!!!!!
Damn! After seeing your DIY RAM instructables I was going to do just this myself. Oh well, beat to the punch. Maybe I'll post a more complete version, with subtraction and such. Good job.
1-40 of 55Next »