Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
4 views3 pages

Embedded Program LAB

The document outlines an experiment to develop a program for shifting LEDs left and right using the 8051 Microcontroller in Embedded C. It includes the necessary apparatus, circuit diagram, source code, and procedure for execution, as well as the expected output of a running light effect. The experiment can be simulated using Proteus and optionally implemented on actual hardware with Flash Magic.

Uploaded by

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

Embedded Program LAB

The document outlines an experiment to develop a program for shifting LEDs left and right using the 8051 Microcontroller in Embedded C. It includes the necessary apparatus, circuit diagram, source code, and procedure for execution, as well as the expected output of a running light effect. The experiment can be simulated using Proteus and optionally implemented on actual hardware with Flash Magic.

Uploaded by

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

EXPERIMENT-01

To develop and execute the program to shift LED’s Left and right to the
Microcontroller 8051

AIM:
To develop and execute a program to shift LEDs left and right using 8051
Microcontroller in Embedded C.

APPARATUS / EQUIPMENTS REQUIRED:

1. 8051 Microcontroller Development Board


2. Keil µVision IDE (for programming)
3. Proteus Design Suite (for simulation)
4. Flash Magic (for burning the hex file)
5. 8 LEDs
6. Resistors (220Ω)
7. Connecting wires
8. Power supply

THEORY

The LED shifting program demonstrates how to control multiple LEDs connected to
the port of an 8051 microcontroller. By shifting a 1 bit across a byte and outputting it
to a port (say P1), we can create a running light effect:

 Left Shift: From P1.0 to P1.7


 Right Shift: From P1.7 to P1.0

CIRCUIT DIAGRAM

 Connect 8 LEDs to Port 1 (P1.0 to P1.7) through current limiting resistors.


 The cathodes of the LEDs are grounded.
 P1.0-P1.7 will be used to display shifting LED patterns.

🔹 SOURCE CODE (Embedded C for Keil)


c
CopyEdit
#include <reg51.h>
#include <intrins.h>

void delay_ms(unsigned int ms) {


unsigned int i, j;
for (i = 0; i < ms; i++)
for (j = 0; j < 1275; j++);
}

void main() {
unsigned char pattern = 0x01; // Start with LSB ON
while (1) {
// Left shift from P1.0 to P1.7
pattern = 0x01;
while (pattern != 0x80) {
P1 = pattern;
delay_ms(300);
pattern <<= 1;
}
// Right shift from P1.7 to P1.0
while (pattern != 0x01) {
P1 = pattern;
delay_ms(300);
pattern >>= 1;
}
}
}

🔹 PROCEDURE

1. Open Keil µVision and create a new project for 8051.


2. Add the above source code file.
3. Compile the code and generate the HEX file.
4. Open Proteus, design the circuit with 8051 and 8 LEDs connected to Port 1.
5. Load the HEX file into the 8051 in Proteus.
6. Run the simulation.
7. Observe the LEDs shift from left to right and back.
8. Optionally, burn the HEX file to the real 8051 board using Flash Magic to
observe on actual hardware.

🔹 EXPECTED OUTPUT

 The LEDs connected to P1.0–P1.7 should glow one after another from left to
right and then back right to left, creating a "running light" or "chaser" LED
pattern.
RESULTS:
To check the output, connect the hardware as shown above diagram, increase the temperature
on the sensor side then we will see the variation on sensor data on both HyperTerminal and
lcd.

You might also like