You are on page 1of 8

Microprocessor & MicroControllers

Lab Mid Exam

Submitted by:
Name:
Mujtaba Ahmed
Reg id:
215001
Submitted to:
Engr Abdul Ghani

Department of Electrical Engineering


Air University Aerospace & Aviation Campus Kamra
Lab Tasks
Lab task 1:
Code:
BUZZER BIT P1.5 SJMP LOOP
ORG 00H
MAIN: DELAY:
MOV P1, #00H MOV R1,#255
LOOP: DELAY_1:
JB P2.3, BUZZER_1 DJNZ R1,DELAY_1
SJMP LOOP RET
BUZZER_1: END
SETB BUZZER
ACALL DELAY
CLR BUZZER
ACALL DELAY

Figure 1 Code Task 1


Output:

Figure 2 TASK 1 OUTPUT WHEN BIT IS LOW(0)

Figure 3 TASK 1 WHEN INPUT IS HIGH(1)


Task 2:
Code:

#include <reg51.h> delay(50);


#define lcd_data P0 en=0;
sbit rs=P1^0; }
sbit rw=P1^1; void show(unsigned char *a)
sbit en=P1^2; {
void init(); while(*a) {
void cmd(unsigned char c); dat(*a++);
void dat(unsigned char b); }
void show(unsigned char *a); }
void delay(unsigned int time); void delay(unsigned int time)
void init() {
{ unsigned int i,j;
cmd(0x38); for(i=0;i<time;i++)
cmd(0x0e); for(j=0;j<1275;j++);
cmd(0x01); }
cmd(0x06); int main()
cmd(0x0c); {
cmd(0x80); unsigned int j;
} init();
void cmd(unsigned char c) while(1) {
{ cmd(0x80);
lcd_data=c; show(" Mujtaba Ahmed ");
cmd(0xc0);
rs=0; show("215001 5th semester");
rw=0; cmd(0x01);
en=1; cmd(0x80);
delay(50); show(" Welcome to ");
en=0; cmd(0xc0);
} show("Air University");
void dat(unsigned char b) for(j=0; j<30000; j++);
{ cmd(0x01);
lcd_data=b; for(j=0; j<30000; j++);
rs=1; }
rw=0; }
en=1;
Code Snapshot In Keil:
Procedure for Practical Implementation:

1. Connect your microcontroller to the super prp burner and then connect it to your PC.
2. Use the Keil software to create a hex file for your code.
3. Open the Super Pro 610p software and import the hex file.
4. Select the AT89C51 microcontroller from the options.
5. Remove id check to proceed.
6. Erase the existing code on the microcontroller.
7. Program the new code onto the microcontroller.
8. Choose the "Auto" option for the programming process.
9. Wait for the programming process to be successful.
10. Once program is uploaded , Microcontroller is ready to be used.
11. After this take the Micro controller and implement the circuit shown in figure of
protues.
12. After patching the circuit on breadboard ,now connect the power supply with vcc and
gnd pins of 8051 microcontrollers
13. Now take pictures of your practical implementation.

You might also like