Docsity

Making an LED Blink - Microprocessor Interfacing - Lab Manual, Exercises of Microprocessor and Interfacing

Toggle sidebar
bg1
Microprocessor Interfacing Lab
Page 1 of 4
Lab 01
Making an LED Blink Using 89C51 Microcontroller
Introduction
In this lab you are going to write a simple program for 89C51 Microcontroller.
Interfacing an LED with its port will make it blink.
So the first step is to build the circuit. Following equipment is needed for performing this
experiment.
Hardware Needed:
S.No. Type Symbol Rating Quantity
Resistor R1 512 Ω ½ watt 01
Resistor R2 10 K Ω ½ watt 01
LED L1 01
Capacitor C1 10 µf 01
Crystal CR1 11 MHz 01
Capacitor C2, C3 33 pf 02
Breadboard 01
Power Supply +5V 01
Circuit Diagram
Docsity.com
pf3
pf4

Partial preview of the text

Download Making an LED Blink - Microprocessor Interfacing - Lab Manual and more Exercises Microprocessor and Interfacing in PDF only on Docsity!

Page 1 of 4

Lab 01

Making an LED Blink Using 89C51 Microcontroller

Introduction

In this lab you are going to write a simple program for 89C51 Microcontroller.

Interfacing an LED with its port will make it blink.

So the first step is to build the circuit. Following equipment is needed for performing this

experiment.

Hardware Needed:

S.No. Type Symbol Rating Quantity

Resistor R1 512 Ω ½ watt 01

Resistor R2 10 K Ω ½ watt 01

LED L1 01

Capacitor C1 10 μf 01

Crystal CR1 11 MHz 01

Capacitor C2, C3 33 pf 02

Breadboard 01

Power Supply +5V 01

Circuit Diagram

Page 2 of 4

Snapshot of Circuit on a breadboard

Programming in C

Write down the following code in a notepad file and save it as lab01.C

#include <AT89C51.H>

void wait (void){ /* wait function / ; / It does nothing, used only to implement / } / delay for LEDs */

void main (void) { unsigned int i; /* Delay variable / unsigned char j; / LED variable */

while (1) /* Loop forever / { for (j=0x01; j< 0x80; j<<=1) { / Blink LEDs 0, 1, 2, 3, 4, 5, 6 / P1 = j; / send Output to Port 1 */

for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts / wait (); / call wait function */ } }

for (j=0x80; j> 0x01; j>>=1) { /* Blink LED 6, 5, 4, 3, 2, 1 / P1 = j; / Output to LED Port / for (i = 0; i < 10000; i++) { / Delay for 10000 Counts / wait (); / call wait function */ } } }

Page 4 of 4

Circuit Diagram