0% found this document useful (0 votes)
2 views

Microcontroller Cp Merged-8

The document describes a microcontroller-based calculator using an AT89C51 microcontroller, a keypad for input, and an LCD for output. It includes C programming code for initializing the LCD, sending commands, and handling delays. The code sets up the necessary functions to process user input and display results on the LCD.

Uploaded by

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

Microcontroller Cp Merged-8

The document describes a microcontroller-based calculator using an AT89C51 microcontroller, a keypad for input, and an LCD for output. It includes C programming code for initializing the LCD, sending commands, and handling delays. The code sets up the necessary functions to process user input and display results on the LCD.

Uploaded by

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

Summary

This diagram shows a simple microcontroller-based calculator where:

• A keypad is used to input numbers and operations.

• An LCD is used to display the result.

• The AT89C51 microcontroller reads the input, processes it, and outputs the result to the
display.

4. 8051 C Programe Code

#include <REGX51.H>

#define LCD P2
sbit RS = P3^5;
sbit RW = P3^6;
sbit EN = P3^7;

unsigned char key;


unsigned int num1 = 0, num2 = 0, result = 0;
char op;

// Delay function
void delay_ms(unsigned int ms) {
unsigned int i, j;
for(i=0; i<ms; i++)
for(j=0; j<127; j++);
}

// LCD command
void lcd_cmd(unsigned char cmd) {
LCD = cmd;
RS = 0;
RW = 0;
EN = 1;
delay_ms(1);
EN = 0;
}

// LCD data
void lcd_data(unsigned char dat) {
LCD = dat;
RS = 1;
RW = 0;
EN = 1;
delay_ms(1);
EN = 0;
}

// LCD initialization
void lcd_init() {
lcd_cmd(0x38);
lcd_cmd(0x0C);
lcd_cmd(0x06);
lcd_cmd(0x01);
lcd_cmd(0x80);
}

Dept of ECE, BIET, Davanagere 6|Page

You might also like