Introduction: Binary to Decimal Calculator

For grade eleven computer engineering, I had to decide on a final project. At first I did not know what to make because it had to include certain hardware components. After a few days, my classmate told me to do a project based off the four bit adder we created a few months ago. After that day, using my four bit adder, I was able to create a binary to decimal converter.

Creating this project requires a lot of research, which includes mainly understanding how a full and half adder works.

Step 1: Materials Needed

For this project, you will be needing the following materials:

  • Arduino UNO
  • four breadboards
  • nine-volt battery
  • seven XOR gates (2 XOR chips)
  • seven AND gates (2 AND chips)
  • three OR gates (1 OR chip)
  • five LEDs
  • eight 330 ohm resistors
  • LCD display
  • four male-female wires
  • lots of male-male wires
  • wire stripper
  • common anode RGB LED

Cost (excluding wires): $79.82

All material's cost were found on ABRA electronics.

Step 2: Understanding 4 Bit Adder

Before we begin, you must understand how a four-bit adder works. When we first look at this circuit, you will notice that there are a half adder circuit and three full adder circuits. Because a four-bit adder is a combination of a full and half adder, I have posted a video explaining how the two types of adder work.

Step 3: Building the 4 Bit Adder

Explaining how to build a four-bit adder is very difficult, as it involves a lot of wiring. Based on these pictures, I can give you some tricks in order to build this circuit. Firstly, the way you arrange your logic chips can be very important. In order to have a neat circuit, order your chips in this order: XOR, AND, OR, AND, XOR. By having this order, not only will your circuit be neat, but it will also be very easy for you to organize.

Another great trick is to build each adder one at a time and from the right side to the left side. A common mistake that many people have done is do all the adders at the same time. By doing this, you could mess up in the wiring. One mistake in the 4-bit adder could cause the whole thing to not work,

Step 4: Providing Power and Ground to the Circuit

Using the 9-volt battery, provide power and ground to the breadboard that is going to contain the four-bit adder. For the remaining 3 breadboards, provide power and ground to it through the Arduino UNO.

Step 5: Wiring LEDs

For this project, the five LEDs will be used as an input and output device. As an output device, the LED will illuminate a binary number, depending on the inputs put into the four bit adder. As an input device, depending on which LEDs are on and off, we will be able to project the converted binary number on the LCD display as a decimal number. To wire the LED, you will connect one of the sums formed by the four bit adder to the anode leg of the LED (long leg of LED), however in between these two, place a 330 ohm resistor. Then connect the cathode leg of the LED (short leg of LED) to the ground rail. In between the resistor and the sum wire, connect a male to male wire to any digital pin on the Arduino UNO. Repeat this step for the three remaining sums and the carry-out. The digital pins I used were 2,3,4,5 and 6.

Step 6: Wiring Common Anode RGB LED

For this project, the purpose of this RGB LED is to change colors whenever a new decimal number is formed on the LCD display. When you first look at the common anode RGB led, you will notice that it has 4 legs; a red-light leg, a power(anode) leg, a green-light leg, and a blue-light leg. The power (anode) leg will be connected to the power rail, receiving 5 volts. Connect the remaining three colour legs with 330 ohm resistors. On the other end of the resistor, use a male to male wire to connect it to a PWM dgital pin on the Arduino. The PWM digital pin is any digital pin with a squiggly line beside it. The PWM pins I used were 9, 10, and 11.

Step 7: Wiring the LCD Display

For this project, the LCD display will project the converted binary number into a decimal. When we look at the LCD display, you will notice 4 male pins. Those pins are VCC, GND, SDA and SCL. For the VCC, use a male to female wire to connect the VCC pin to the power rail on the breadboard. This will provide 5 volts to the VCC pin For the GND pin, connect it to the ground rail with a male to female wire. With the SDA and SCL pins, connect it to an analog pin with a male to femal wire. I connected the SCL pin to analog pin A5 and the SDA pin to analog pin A4.

Step 8: Writing the Code

Now that I have explained the building part of this project, lets now begin code. Firstly, we need to first download and import the following libraries; LiquidCrystal_I2C library, and the wire library.


Once you have done this, you need to declare all the necessary variables. In any type of code, you must declare your variables first.

const int digit1 = 2;

const int digit2 = 3;

const int digit3 = 4;

const int digit4 = 5;

const int digit5 = 6;

int digitsum1 = 0;

int digitsum2 = 0;

int digitsum3 = 0;

int digitsum4 = 0;

int digitsum5 = 0;

char array1[]="Binary to Decimal";

char array2[]="Converter";

int tim = 500; //the value of delay time

const int redPin = 9;

const int greenPin = 10;

const int bluePin = 11;


LiquidCrystal_I2C lcd(0x27, 16, 2);

In the void setup(), you declare the pin type for all your variables. You will also use a serial begin because we are using analogWrite().

void setup()



pinMode(digit1, INPUT);

pinMode(digit2, INPUT);

pinMode(digit3, INPUT);

pinMode(digit4, INPUT);

pinMode(digit5, INPUT);



pinMode(redPin, OUTPUT);

pinMode(greenPin, OUTPUT);

pinMode(bluePin, OUTPUT);

In the void setup(), I created a for loop to create a message saying the name of this project. The reason why it is not in the void loop() is that if it is in that void, the message will keep on repeating.

lcd.setCursor(15,0); // set the cursor to column 15, line 0

for (int positionCounter1 = 0; positionCounter1 < 17; positionCounter1++)


lcd.scrollDisplayLeft(); //Scrolls the contents of the display one space to the left.

lcd.print(array1[positionCounter1]); // Print a message to the LCD.

delay(tim); //wait for 250 microseconds


lcd.clear(); //Clears the LCD screen and positions the cursor in the upper-left corner.

lcd.setCursor(15,1); // set the cursor to column 15, line 1

for (int positionCounter = 0; positionCounter < 9; positionCounter++)


lcd.scrollDisplayLeft(); //Scrolls the contents of the display one space to the left.

lcd.print(array2[positionCounter]);// Print a message to the LCD.

delay(tim);//wait for 250 microseconds


lcd.clear(); //Clears the LCD screen and positions the cursor in the upper-left corner.


Now that we have finished the void setup(), let's move onto the void loop(). In the void loop, I created several if-else statements to make sure that when certain lights are on or off, it will display a certain decimal number on the display. I have attached a document showing what's inside my void loop and the many other voids I have created. Click here to visit the document.

Now all you have to do is run the code and enjoy your new binary to decimal converter.