Introduction: 4 Bit Adder With Base Ten Display

This project takes a four bit adder which is normally displayed in binary though the usage of leds and instead uses the 7447 seven segment decoder and Arduino to compliment each other in their translation of the output of the binary adder into being displayed in ten base on seven segment displays.

Step 1: Materials(Needed)

Step 2: Cost Break Down

Links to the materials

XOR Gates

AND Gates

OR Gates

IC 7447 BCD to 7 Segment Decoder

Common Anode Seven Segment Displays

10k ohm Resistors

300 ohm Resistors

Standard 4 Position DIP Switch

Arduino Uno R3

*You will also need wires and a minimum of two breadboards*
*While LEDs are not needed for this project it's recommended you have at the very least a total of 5 to test the output of your adder*

Step 3: Full Schematics

Who those who are more experienced and wish to begin building here is a full schematic. Here is a link to an intractable schematic.

The code can be found at the end of instructable.

Step 4: Building the Adder

The first step is to build your 4-bit adder however, before you begin building the 4-bit adder it is important that you plan out the entire layout of all your wiring, due to the limited space provided by one breadboard. This can be done in a program such as Tinkercad. Once you have planned out your build it is highly recommended you build your adder bit by bit and test out the result after the completion of each bit. This largely due to troubleshooting and to make it easier to catch possible issues that can occur when building a 4 bit adder in one go. Testing can be done with LEDs. Looking at the diagram above when building your adder remember that a 4 bit adder is merely an extension of a 2 bit adder with each additional bit a repeat of subsequent combination of logic gates not inducing the very first. Also when using dip switches remember to use the 10k ohm resistors as pull up resistors to ensure the state of switch is properly controlled and correctly outputs ground or power when the switch is flipped.

Step 5: Completed 4-bit Adder

Once you are positive you adder is fully functional you can now connect the outputs of the adder into the analog-in pins of the Arduino remember to record which pin is connected to each respected bit.

Step 6: Coding

Set the analog-in pins as a integer variable. Remember when naming your variable to note what place value the variable represents in my case "led1" is the right most output of 4-bit adder. The next step is to take your variable and multiply it (5.0/1023.0) this will provide you with a usable voltage value that you have to set to a newly create float variable. In my case I will use "voltage" differentiated by the numerical value of the LED it represents. Finally I will create a integer variable in my case I will call it "baseten" as it holds the base ten value of my adder. Once you have a new created integer value and you have set it to 0, a series of if statements will be used to increment this value. The condition of these if statements will be your "voltage" variables having a value greater than 0. So because "voltage1" represent the 1s column for our binary output we would increment our "baseten" variable by 1 if we read a voltage of greater than 0. This train of thought continues for the rest of the values. Finally you would want to test your code by using the Serial.println function with your variable at the end to see if you have converted your binary output into its base ten value correctly in my case I used Serial.println(baseten). Just randomly input values into your adder to see if the output is properly translated.

Step 7: Setting Up Your Display

For this project I will be using 2 7447 BCD seven segment displays decoders for this project. Because one of these devices is only able to translate a 4-bit output both an Arduino and another BCD decoder is required, it should also be noted that an Arduino alone lacks the pins to output to every pin of the seven segment display. So a combination of the two will be used to solve this issue, with the Arduino separating the tens and ones place values, which allows each BCD seven segment decoder to handle outputting one of those values to a seven segment display, This video does a great job of explaining how to set up a 7447 with a 7 segment display, all you need to do is to replace the dip switch with Arduino pin just be sure to record which pins handle is representing each bit.

Step 8: Coding the Output

Now your first job is to initialize the pins you have decided to use for your 7447 BCD 7 seven segment decoders. When labeling them it's important to note which pins handle what bit of the output. For example "a1" is responsible for the right most bit which only holds a value of 1, and "b4" would hold a value of 8. To expand upon this, the 4 designated pins of the 7447 will either receive a high or low output from the Arduino to simulate what would happen if the 7447 were connected to normal binary output. So for example because of the earlier code we are able to accurately translate the binary output of our 4 bit adder, so let's say we read an output of 00101, this would have a value of 5 in base ten thus our 7447 BCD will require and output of HIGH towards b1 and b3 to get our 7 segment display to display a 5. However, we would need to think differently with a 2 place value base ten digit. This is where our second 7447 decoder comes into play and also explains why we need an Arduino. We simply need to separate the number within each place value and display them on different 7 segment displays. One decoder will help display the ones column, while the other will focus on the tens place. This step is quite simple. We just require a series of if and if else statements, if our translated value is less than 10 it must be a number 0 through 9, if our number is less than 20 it must be a number between 10 through 19 this train of thought continues. However once we know it's greater than 10 we must subtract the tens place value from our base ten value. So if we had a value of 19 we would subtract 10, if it was 23 we would subtract 20. This is so that we can now convert the ones digit using code, using the method that was mentioned before, simply output a value of either high or low from their designated pins. Remember it's important to list these in ascending order such that it will cycle through all the possible values.

Step 9: Code

Here is the code for you to use. Remember to check your wiring with the initialized pins and ensure that they are representing the proper bit. "a1" and "b1" represents the right most bit and its moves left as you go down.

Step 10: Completed

At this point you can test our your 7 segment display should be displaying the base ten value of your 4 bit adder.