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.
We will explore two modes:
- Normally High, low when pressed.
- Normally Low, high when pressed.
Two circuit configurations with Pull-Up and Pull-Down techniques are demonstrated below.
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
AT89C51 Microcontroller | Push Button Debounce | Assembly Language | Proteus Simulation | Microcontroller Programming
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 |
-
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
-
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
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.
Without debouncing, a single press may register multiple times due to rapid bouncing. This can cause erratic behavior in your system.
-
Hardware Debouncing: Use a capacitor across the switch contacts to smooth out the bouncing effect.
-
Software Debouncing: Add a small delay in your code to allow the switch to stabilize before reading the final state.
#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
}
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 |
-
Clone the Repository:
git clone https://github.com/your-repo/8051-Push-Button.git
-
Compile the Assembly Code: Open the
AT89C51_Push_Button.asm
in an 8051 IDE, and compile it to generate the HEX file. -
Simulate in Proteus: Open Proteus Design Suite and load the provided simulation file.
-
Program the Microcontroller: Upload the HEX file to your AT89C51 microcontroller and test the circuit with real hardware.
We welcome contributions! Feel free to submit pull requests or open issues to suggest improvements.
For questions or assistance, contact me at [email protected].
Give this repository a β if you find it helpful!