Interfacing Switch: 8051 Development Board
Interfacing Switch: 8051 Development Board
Fig. 1 shows how to interface the switch to microcontroller. A simple switch has an
open state and closed state. However, a microcontroller needs to see a definite high
or low voltage level at a digital input. A switch requires a pull-up or pull-down resistor
to produce a definite high or low voltage when it is open or closed. A resistor placed
between a digital input and the supply voltage is called a “pull-up” resistor because it
normally pulls the pin’s voltage up to the supply.
Fig. 1 Interfacing
switch to Microcontroller
The 8051 Development board has eight numbers of point LEDs, connected with I/O
Port lines (P0.0 – P0.7) to make port pins high. Eight switches, connected with I/O port
lines (P2.0 – P2.7) are used to control eight LEDs.
Pin Assignment with 8051
**********************************************************************************
*****
#include
#define SW P2
#define Led P0
//----------------------
// Main Function
//----------------------
void main()
P2=0xff;
//Port-2
//Loop Forever
Led = ~SW;