| |
Microcontroller program for LCD:
This program is written by the compiler PIC basic.
DEVICE = 16F877 ' We'll use a PIC16F877 PIC micro
XTAL = 4 ' With a 4MHz crystal
dim ahmed as dword
dim mmm as dword
dim x as byte
trisb = 0
trisd = 128
trisc=0
trise=0
adcon0=0
adcon1= 7
TRISA = 63
ahmed = 0
mmm = 0
x = 0
cls
start:
if porta.0=1 and porta.1=0 then
portd.0=1
print at 2,1, "Obstacle: Right"," "
endif
if porta.1=1 and porta.0=0 then
portd.0=1
print at 2,1, "Obstacle: Left"," "
endif
if porta.1=1 and porta.0=1 then
portd.0=1
print at 2,1, "Obstacle: Both"," "
endif
if porta.1=0 and porta.0=0 then
portd.0=0
print at 2,1, "NO Error"," "
endif
if porta.2=1 and ahmed = 0 then
x= x + 1
endif
if porta.2=1 then
ahmed= ahmed + 1
ELSE ahmed = 0
endif
if porta.3=1 and mmm = 0 then
x= x - 1
endif
if porta.3=1 then
mmm = mmm + 1
ELSE mmm = 0
endif
if x > 10 then x = 0
print at 1,1, "No of BOXES: ",dec x," "
if portd.7=1 then goto setting
delayms 200
goto start
setting:
print at 1,1, "Setting mode:-"," "
print at 2,1, "No of BOXES: ",dec x," "
if porta.0=1 then cls
if porta.5=1 then x= x + 1
delayms 500
if x > 10 then x = 0
if portd.7=1 then goto setting
goto start |
|