An open API service indexing awesome lists of open source software.

https://github.com/gmostofabd/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.
https://github.com/gmostofabd/8051-push-button

8051 assembly circuit debouncing digital download hex input mcu microcontroller programming proteus pull-down pull-up read schematic simulation switch

Last synced: 28 days ago
JSON representation

🔗 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.

Awesome Lists containing this project

README

          

# ⚙️ **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](https://www.atmel.com/products/microcontrollers/8051.aspx)** | **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**:
```text
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**:
```text
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:
```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**:
```bash
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](mailto:mostofa.melab@gmail.com).

---

Give this repository a ⭐ if you find it helpful!