0% found this document useful (0 votes)
14 views9 pages

Embedded Lab 08-22BEC1098

The document outlines Lab Assignment 08 for the Embedded C Lab at the School of Electronics Engineering, focusing on controlling I/O ports on microcontroller hardware. It includes three C programs for LED operations: blinking a single LED, alternating two LEDs, and monitoring a pin to send specific values to another port. The assignment aims to enhance understanding of microcontroller port manipulation and hardware interfacing.

Uploaded by

advikram2512
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)
14 views9 pages

Embedded Lab 08-22BEC1098

The document outlines Lab Assignment 08 for the Embedded C Lab at the School of Electronics Engineering, focusing on controlling I/O ports on microcontroller hardware. It includes three C programs for LED operations: blinking a single LED, alternating two LEDs, and monitoring a pin to send specific values to another port. The assignment aims to enhance understanding of microcontroller port manipulation and hardware interfacing.

Uploaded by

advikram2512
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/ 9

School of Electronics Engineering (SENSE)

BECE320E - Embedded C Lab

Lab Assignment: 08

Submitted By
Surya Thangaraju | 22BEC1098

Submitted To
Krithika Alias Anbu Devi m

DATE: 17.02.2025
Lab-6 Programs on I/O Ports (Hardware)

Attestation:

Aim:
To develop and implement C programs for controlling I/O ports on microcontroller hardware to
perform various LED operations, including blinking a single LED, alternating two LEDs, switching
ON one LED while others are OFF, and interfacing hardware to display specific patterns using I/O
ports.
1. Write a C program to blink an LED.

Code:
#include <reg52.h>

sbit LED = P1^0; // LED connected to Port 1, Pin 0

void Delay(void);

void main(void) {
while(1) {
LED = 0; // Turn ON LED
Delay();
LED = 1; // Turn OFF LED
Delay();
}
}

void Delay(void) {
int i, j;
for(i = 0; i < 10; i++) {
for(j = 0; j < 1275; j++) {
// Empty loop to create delay
}
}
}
Output:
2. Write a C program to blink 2 alternate LEDs.
Code:
#include <reg52.h>

sbit LED1 = P1^0; // LED 1 connected to Port 1, pin 0


sbit LED2 = P2^0; // LED 2 connected to Port 2, pin 0

void Delay(void);

void main(void) {
while(1) {
LED1 = 0; // Turn on LED 1
LED2 = 1; // Turn off LED 2
Delay();
LED1 = 1; // Turn off LED 1
LED2 = 0; // Turn on LED 2
Delay();
}
}
void Delay(void) {
int i, j;
for(i = 0; i < 10; i++) {
for(j = 0; j < 1275; j++) {
// Empty loop to create delay
}
}
}
Output:
3. Hardware implementation of Lab-6 (Exp.-3).

Write a 8051 C program to monitor the P2.5,if it is High it Sends 55H to


Port-1 and sends AAH if low.

Code:

#include<reg51.h>
sbit mbit=P2^5;
void main(void){
mbit=1;
while(1){
if (mbit==1)
P1=0x55;
else
P1=0xAA;
}
}
Output:
Inference:
The three C programs collectively demonstrate the fundamental techniques of
controlling I/O ports on microcontroller hardware, specifically focusing on LED
operations and hardware pattern generation. These experiments serve as practical
exercises for understanding microcontroller port manipulation and hardware
interfacing.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy