A 2-Bit Adder Learning and Battle Game Using Arduino

by 1040234 in Circuits > Arduino

43 Views, 1 Favorites, 0 Comments

A 2-Bit Adder Learning and Battle Game Using Arduino

https://www.instructables.com/A-2-Bit-Adder-Learning-and-Battle-Game-Using-Ardui/ #instructable
IMG_0956.jpg
IMG_0958.jpg

Hello! My name is Rehman and this project is a 2-bit binary adder using logic gates and an Arduino, combined with an interactive LCD game mode.

This project takes two binary numbers, adds them using a real digital logic circuit, and then displays the result in both decimal and binary. To make it more engaging, I added a two-player conversion game using a keypad and buzzer, where players must convert between decimal and binary.

This project helped me understand:

  1. How computers use binary math
  2. How logic gates perform addition
  3. How hardware and software work together
  4. How to design a user-interactive system

Although it may look complex at first, everything is broken down step by step, making it beginner-friendly.

Step 1: How the Project Works (Overview)

This project has two modes:

At the start screen display asks select a mode Press A for Mode A and B for Mode B. You can change the mode by pressing B on the keypad anytime and change to mode A after the game is over.

Mode A – Normal Adder Mode

  1. Reads the output of a 2-bit adder circuit
  2. Displays:
  3. Decimal value
  4. Binary value (3 bits)
  5. Updates as switches change and A pressed of the keypad

Mode B – Game Mode

  1. Two players
  2. Best of 3 rounds
  3. LCD randomly shows Decimal or Binary
  4. Player must enter the value using the keypad
  5. to enter the value press * or # for player 1 or 2 and to lock in the answer press the same (* or #) which ever one was pressed first.
  6. Correct answers earn points out of 3
  7. Buzzer gives sound feedback
  8. Winner is announced on the LCD

Supplies

OIP.jpg
FGAP8R3MBP3TZ0H.png

For this project you will require (links are included):

1x Standard 4 Position DIP Switch $0.98

1x Keypad $12

1x LCD $14

1x XOR Logic Gate $2.41

1x AND Logic Gate $0.95

1x OR Logic Gate $1.80

4x 10kΩ Resistors 0.40

5x 330Ω Resistors $0.50

1x Arduino UNO R3 $15.99

1x Wire Pack $14.99

1x Breadboard $4.99

Total Project Cost:

$69.31

Understanding the 2-Bit Adder

A 2-bit adder is made using two half adders:

  1. First half adder adds the least significant bits
  2. Second half adder adds the most significant bits and carry

Outputs:

  1. S0 → 1’s place
  2. S1 → 2’s place
  3. C2 → 4’s place

Together, they form a 3-bit binary number (0–6).

Wiring the 2-Bit Adder

FELLTJGMBP3XCHC.png
IMG_0951 (1).jpg
  1. DIP switch inputs → logic gates
  2. Logic gate outputs → Arduino pins:
  3. S0 → D2
  4. S1 → D3
  5. C2 → D4

These pins allow the Arduino to read the adder result.

Wiring the LCD

The LCD uses I²C, which only needs 4 wires:

LCD Pin Arduino Pin

VCC → 5V

GND → GND

SDA → A4

SCL → A5

The LCD displays all instructions, values, and game results.

Wiring the Keypad

IMG_0955.jpg

The keypad is used for:

  1. Entering numbers
  2. Selecting players
  3. Choosing game mode

Example wiring:

Keypad Pin Arduino

R1 → D5

R2 → D6

R3 → D7

R4 → D8

C1 → D9

C2 → D10

R3 → D11

R4 → D12

Wiring the Buzzer

  1. Positive leg → A0
  2. Negative leg → GND

The buzzer provides sound feedback:

  1. Mode change
  2. Correct answer
  3. Wrong answer
  4. Game winner

Mode a – Normal Display Mode

IMG_0952.jpg

In this mode:

  1. Arduino reads S0, S1, and C2
  2. Converts the value to decimal and binary
  3. Displays both on the LCD
  4. Updates every time A is pressed on key board

Example:

Decimal: 4

Binary: 100

Mode B – Game Mode

IMG_0957.jpg

Mode B – Game Mode

How to Play:

  1. Press B on the keypad to start
  2. LCD shows Decimal or Binary
  3. Press:
  4. * for Player 1
  5. # for Player 2
  6. Enter the other format
  7. Correct answer = 1 point
  8. After 3 rounds, winner is displayed


Code

Final Thoughts

This project combines:

  1. Digital logic
  2. Binary math
  3. Programming
  4. User interaction

It helped me understand how real computers perform calculations and how hardware and software work together. The game mode also makes learning binary more fun and competitive.