Skip to content

About

4-bit full adder codes on AtMEGA16 microcontroller written in Assembly

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

4-Bit Full Adder Using ATmega16

Project Overview

This project implements a 4-bit Full Adder using the ATmega16 microcontroller. It computes the sum and carry-out for two 4-bit binary inputs along with a carry-in signal. The results are displayed using LEDs connected to the microcontroller.


✨ Features

  • 4-bit Binary Addition:
    • Adds two 4-bit numbers (A and B) with a carry-in (Cin).
    • Outputs the Sum and Carry-out (Cout) on LEDs.
  • Dynamic Input Handling:
    • Reads inputs directly from PORTA, PORTB, and PINB.
  • Assembly Language Implementation:
    • Efficient and optimized for microcontroller use.

📋 Table of Contents

  1. Overview
  2. Requirements
  3. Setup Instructions
  4. How It Works
  5. Project Diagrams
  6. References
  7. License

🛠️ Requirements

Hardware:

  • ATmega16 Microcontroller //1MHz internal clock used here
  • LEDs (5) with 330 Ω resistors
  • Push buttons (for binary inputs)
  • Breadboard and jumper wires
  • 5V Power Supply

Software:


🚀 Setup Instructions

  1. Assemble the Circuit:

    • Connect inputs (A, B, and Cin) to PORTA, PORTB, and PINB, respectively.
    • Connect outputs (Sum and Carry) to PORTC, where LEDs are attached.
    • Use pull-down resistors with input buttons for stable signals.
  2. Load the Assembly Code:

    • Open 4bit_full_adder.asm in AVR Studio.
    • Compile the file to generate the .hex file.
  3. Program the Microcontroller:

    • Use a suitable programmer (e.g., USBasp) to flash the .hex file to the ATmega16.
  4. Run the Simulation:

    • Simulate the circuit using Proteus to validate functionality.
    • Test the hardware circuit with various input combinations.

⚙️ How It Works

  1. Initialization:

    • Input ports (PORTA and PORTB) are configured as inputs.
    • Output port (PORTC) is configured to drive LEDs.
  2. Input Handling:

    • Binary values for A and B are read from PORTA and PORTB.
    • Cin is derived from the 5th bit of PINB (via SBRC and SBRS instructions).
  3. Calculation:

    • A, B, and Cin are added using the ADD instruction.
    • Carry-out is detected using bitwise operations.
  4. Output Display:

    • Sum and Carry-out values are written to PORTC, lighting up the corresponding LEDs.

📊 Project Diagrams

Circuit Diagram

  • Example: A = 6 , B = 4, Cin = 1 (in decimal) || Sum = 11, Cout = 0 (in decimal)

Circuit Diagram

Flowchart

Flowchart

Pinout Diagram

Pinout


🔗 References

About

4-bit full adder codes on AtMEGA16 microcontroller written in Assembly

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages