0% found this document useful (0 votes)
67 views4 pages

Interfacing Switch: 8051 Development Board

Uploaded by

Vikaskumar Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views4 pages

Interfacing Switch: 8051 Development Board

Uploaded by

Vikaskumar Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Interfacing Switch

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

Interfacing Switch with 8051


We now want to control the LED by using switches in 8051 Development board. It
works by turning ON a LED & then turning it OFF when switch is going to LOW or
HIGH.

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

Circuit Diagram to Interface Switch with


8051
Source Code
The Interfacing switch with 8051 program is very simple and straight forward, that
controls led by using switches when it going LOW or HIGH.

C Program to switch functions using 8051


**********************************************************************************
*****

Title : Program to Blink LEDs controlling by switches

**********************************************************************************
*****

#include

//Define 8051 Registers

#define SW P2

//Define Switch to Port2

#define Led P0

//Define Led to Port0

//----------------------

// Main Function

//----------------------
void main()

P2=0xff;

//Port-2

as input to FFh P0=0x00;

//Port-0 as output to 00h while(1)

//Loop Forever

Led = ~SW;

//Assign the Switch value to Led

You might also like