Skip to content

πŸ”— This repository guides you to learn about digital input reading using an 8051 Microcontroller. The program is written in Assembly language and well-commented to ensure clarity. To read the digital input, two tactile push button switches are connected to I/O pins.

Notifications You must be signed in to change notification settings

gmostofabd/8051-Push-Button

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

40 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

βš™οΈ 8051 Push Button

This repository guides you to learn about digital input reading using an 8051 Microcontroller. The program is written in Assembly language and well-commented to ensure clarity. To read the digital input, two tactile push button switches are connected to I/O pins.

AT89C51 UP DN COUNTER 7 Segment

We will explore two modes:

  1. Normally High, low when pressed.
  2. Normally Low, high when pressed.

Two circuit configurations with Pull-Up and Pull-Down techniques are demonstrated below.


πŸ“– Overview

This project uses push buttons to read digital input on an AT89C51 microcontroller. It covers essential concepts of switch debouncing to ensure reliable button presses. The repository includes:

  • Assembly Code
  • Precompiled HEX file
  • Proteus Simulation Circuit

πŸ”‘ Keywords

AT89C51 Microcontroller | Push Button Debounce | Assembly Language | Proteus Simulation | Microcontroller Programming


πŸ› οΈ Hardware & Circuit Information

Component Description
AT89C51 Microcontroller Controls the system and reads the input from push buttons
Push Buttons Two tactile switches configured with pull-up or pull-down
Resistors Current-limiting for protecting input pins and the MCU
Capacitor For hardware debouncing (optional)
Power Supply 5V DC for the microcontroller circuit

Circuit Configuration: Pull-Up and Pull-Down Techniques

  1. Pull-Up Configuration: The input pin is connected to a high voltage (logic HIGH) via a resistor, and pressing the button connects the pin to ground (logic LOW).

    Pull-Up Circuit:

    VCC ----[R]---- Input Pin
                     |
                   Switch
                     |
                    GND
    
  2. Pull-Down Configuration: The input pin is connected to ground (logic LOW) via a resistor, and pressing the button connects the pin to a high voltage (logic HIGH).

    Pull-Down Circuit:

    GND ----[R]---- Input Pin
                     |
                   Switch
                     |
                    VCC
    

πŸ› οΈ Switch Debounce

When you press a mechanical switch, the contacts may bounce before stabilizing, leading to multiple readings of a single press. This effect is called bouncing, and it can cause unreliable behavior in your microcontroller program.

Why is Debouncing Necessary?

Without debouncing, a single press may register multiple times due to rapid bouncing. This can cause erratic behavior in your system.

Techniques for Debouncing

  1. Hardware Debouncing: Use a capacitor across the switch contacts to smooth out the bouncing effect.

  2. Software Debouncing: Add a small delay in your code to allow the switch to stabilize before reading the final state.

Example of Software Debouncing in C:

#define DEBOUNCE_DELAY 50 // 50 milliseconds

int debounceSwitch(int pin) {
  if (digitalRead(pin) == HIGH) {   // if the switch is pressed
    delay(DEBOUNCE_DELAY);          // wait for the debounce period
    if (digitalRead(pin) == HIGH) { // check the state again
      return 1;                     // switch is pressed
    }
  }
  return 0;                         // switch is not pressed
}

πŸ“¦ Repository Contents

File Description
AT89C51_Push_Button.asm Assembly code for reading push buttons
AT89C51_Push_Button.hex Precompiled HEX file for microcontroller programming
Proteus_Push_Button_Simulation.pdsprj Proteus simulation file for testing the circuit
Screenshots Images of the simulation and real hardware testing

πŸš€ How to Use

  1. Clone the Repository:

    git clone https://github.com/your-repo/8051-Push-Button.git
  2. Compile the Assembly Code: Open the AT89C51_Push_Button.asm in an 8051 IDE, and compile it to generate the HEX file.

  3. Simulate in Proteus: Open Proteus Design Suite and load the provided simulation file.

  4. Program the Microcontroller: Upload the HEX file to your AT89C51 microcontroller and test the circuit with real hardware.


🀝 Contributing

We welcome contributions! Feel free to submit pull requests or open issues to suggest improvements.


πŸ“§ Contact

For questions or assistance, contact me at mostofa.melab@gmail.com.


Give this repository a ⭐ if you find it helpful!

About

πŸ”— This repository guides you to learn about digital input reading using an 8051 Microcontroller. The program is written in Assembly language and well-commented to ensure clarity. To read the digital input, two tactile push button switches are connected to I/O pins.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published