ARDU-8051 Virtual Lab

Experiment — Push Button with Software Debouncing

8051 Assembly Program (Debounced Input)

ORG 0000H MAIN: JB P3.2, MAIN ; wait for button press (active LOW) ACALL DEBOUNCE CPL P1.0 ; toggle LED WAIT_RELEASE: JNB P3.2, WAIT_RELEASE SJMP MAIN DEBOUNCE: MOV R7,#50 D1: MOV R6,#255 D2: DJNZ R6,D2 DJNZ R7,D1 RET END
Button (P3.2): 1
LED (P1.0): 0

Hardware Visualization

Port-1 (HEX): 00
Port-3 (HEX): FF
Concept:
Mechanical switches bounce. The delay routine ensures only a single valid press is detected.