Liquid Water Level Indicator With Alarm Using 8051 Microcontroller AT89C51 Code Verifyed

You might also like

Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 2

// Program to make a Liquid level indicator using LCD

#include<reg51.h>
sbit rsP1!"# //register select $in
sbit r%P1!1# //read/%rite $in
sbit eP1!&# //enable $in
sbit quatP'!"# //$in connected to quater level o( tank
sbit hal(P'!1# //$in connected to hal( level o( tank
sbit quat)'P'!&# //$in connected to three *(ourth level o( tank
sbit (ullP'!'# //$in connected to (ull level o( tank
sbit s$kr)onP'!+#
sbit s$kr)o((P'!5# // $in to o(( s$eaker
void dela,-int k. //dela, (unction
/
int i01#
(or-i"#i<k#i22.
(or-1"#1<1&35#122.#
4
void %rite-int 1. //%rite (unction
/
rs1# //selecting command register
r%"# //selecting to %rite
P&1# //$utting value on the $ins
e1# //strobe the enable $in
dela,-1.#
e"#
return#
4
void cmd-int 1. //command (unction
/
P&1# //$ut the value on $ins
rs"# //selecting command register
r%"# //selecting to %rite
e1# //strobe enable $in
dela,-1.#
e"#
return#
4
void $uts-char 5a. //$uts (unction to $rint a string
/
unsigned int $"#
(or-#a6$78"#$22.
%rite-a6$7.#
4
void lcd)init-void. // (unction to initialise the LCD
/
cmd-"9':.# //setting :*bit inter(ace0 & lines0 553 Pi9els
dela,-1.#
cmd-"9"e.# //turning on underline visible cursor
dela,-1.#
cmd-"9"1.# //clearing screen
cmd-"9:".# //moving cursor to the begining o( line 1 o( LCD
4
void main-.
/
quathal(quat)'(ulls$kr)o((1# //con(iguring as in$ut $ins
quathal(quat)'(ulls$kr)o(("# //lo%ering in$ut $ins
s$kr)on1# // making s$eaker on $in high0as it %orks on negative logic
%hile-1.
/
%hile-quat";;hal(";;quat)'";;(ull";;s$kr)o((". //condition %hen tank is em$t,
/
lcd)init-.# // initialising LCD
$uts-<=>C>?@<.# //$rinting =>C>?@ on lcd
4
%hile-quat1;;hal(";;quat)'";;(ull";;s$kr)o((". //condition %hen tank is
quater
/
lcd)init-.#
$uts-<AB>@CD<.# //$rinting AB>@CD on lcd
4
%hile-quat1;;hal(1;;quat)'";;(ull";;s$kr)o((". //condition %hen tank is
hal(
/
lcd)init-.#
$uts-<E>LF<.# //$rinting E>LF on lcd
4
%hile-quat1;;hal(1;;quat)'1;;(ull";;s$kr)o((". //condition %hen tank is
three*(ourth
/
lcd)init-.#
$uts-<'/+ FBLL<.# //$rinting '/+ FBLL on lcd
4
%hile-quat1;;hal(1;;quat)'1;;(ull1;;s$kr)o((". //condition %hen tank is
(ull
/
lcd)init-.#
$uts-<FBLL#CLGHC @>P<.# //$rinting FBLL#CLGHC @>P on lcd
s$kr)on"#// Cnabling s$eaker
4
%hile-quat1;;hal(1;;quat)'1;;(ull1;;s$kr)on";;s$kr)o((1.//enabling high
s$eaker)o(( $in
/
s$kr)on1#//disabling s$eaker
4
4
4

You might also like