You have no items in your shopping cart.

Subtotal: 0.00

How to Interface Switch with 8051 Advanced Development Board

8051 Advanced Development Board

The 8051 Advanced Development Board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through serial port.

NXP’s 8051 (AT89V51RD2), 8051 Advanced Development Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of speed 8-bit Microcontrollers.

Switch

A switch is an electrical component that can break an electrical circuit, interrupting the current or diverting it from one conductor to another. A switch may be directly manipulated by a human as a control signal to a system, or to control power flow in a circuit.

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 Advanced Development Board. It works by turning ON a LED & then turning it OFF when switch is going to LOW or HIGH.

The 8051 Advanced 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



 

Slide Switch

8.51 Lines

Input Logic Selection

DIGITAL INPUTS

SW8

P2.0





SW13

P2.1

SW14

P2.2

SW19

P2.3

SW20

P2.4

SW25

P2.5

SW26

P2.6

SW27

P2.7

 

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

}

}