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

Document 5

The document contains a C program for a fire alarm system using an embedded microcontroller. It initializes an LCD display and continuously checks a flame sensor, displaying alerts on the LCD and activating a buzzer when a fire is detected. Key functions include initializing the LCD, sending commands and data to it, and implementing a delay to prevent flickering.

Uploaded by

Tasneem Nadira
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)
4 views3 pages

Document 5

The document contains a C program for a fire alarm system using an embedded microcontroller. It initializes an LCD display and continuously checks a flame sensor, displaying alerts on the LCD and activating a buzzer when a fire is detected. Key functions include initializing the LCD, sending commands and data to it, and implementing a delay to prevent flickering.

Uploaded by

Tasneem Nadira
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/ 3

PROJECT: FIRE ALARM SYSTEM

#include <reg51.h>
sbit sensor = P1^0;
sbit rs = P1^1;
sbit rw = P1^2;
sbit en = P1^3; // Missing in your code
sbit buzzer = P3^0;
void lcdint();
void lcddat(unsigned char);
void lcdcmd(unsigned char);
void lcddis(unsigned char *);
void delay();
void main() {
buzzer = 0;
sensor = 0;
lcdint();
while(1) {
lcdcmd(0x01);
lcddis("FIRE ALERT"); // Display heading
lcdcmd(0xC0);
lcddis(" SYSTEM");
delay();
if(sensor == 1) { // Flame detected
lcdcmd(0x01); // Clear LCD
lcddis("FIRE OCCURRED");
buzzer = 1;
} else {
buzzer = 0;
}
delay(); // Add delay to avoid flickering
}
}
void lcdint() {
lcdcmd(0x38); // 2 lines, 5x7 matrix
lcdcmd(0x0C); // Display ON, cursor OFF
lcdcmd(0x06); // Auto increment cursor
lcdcmd(0x01); // Clear display
lcdcmd(0x80); // Cursor to first line
}
void lcdcmd(unsigned char val) {
P2 = val;
rs = 0;
rw = 0;
en = 1;
delay();
en = 0;
}
void lcddat(unsigned char dat) {
P2 = dat;
rs = 1;
rw = 0;
en = 1;
delay();
en = 0;
}
void lcddis(unsigned char *s) {
while(*s) {
lcddat(*s++);
}
}
void delay() {
unsigned int v1;
for(v1 = 0; v1 < 10000; v1++);
}

You might also like