New Text Document

You might also like

You are on page 1of 2

SOFTWARE

#define RS PORTD.F0
#define EN PORTD.F1
#define RW PORTD.F2
//PORTC.F0 is used for sensor rod
#define MOTOR PORTC.F2
//-----------------------Lcd comd---------void lcdcmd(unsigned char cmd)
{RS=0;
PORTB=cmd;
EN=0;
Delay_Ms(2);
EN=1;
Delay_Ms(50);
}
//-----------------------Lcd data---------void lcddata(unsigned char data)
{RS=1;
PORTB=data;
EN=0;
Delay_Ms(2);
EN=1;
Delay_Ms(50);
}
//-----------------------Device init-----void DeviceInit(void)
{TRISB=0x00;
TRISD=0x00;
TRISC=0x01;
PORTB=0x00;
PORTD=0x00;
PORTC=0x00;
}
//---------------------Lcd init---------void LcdInit(void)
{
RW=0;
lcdcmd(0x38);
lcdcmd(0x38);
lcdcmd(0x38);
lcdcmd(0x0C);
lcdcmd(0x06);
lcdcmd(0x01);
}
//---------------------msg--------------void mess(unsigned char name[])
{unsigned char i=0;
while(name[i]!='\0')
{lcddata(name[i]);
i++;
}
}
//------------------Main fun------------void main(void)

{DeviceInit();
LcdInit();
while(1)
{while(!PORTC.F0)
{MOTOR=1;
LcdInit();
mess(" motor on");
Delay_Ms(50);
}
MOTOR=0;
LcdInit();
mess(" motor off");
Delay_Ms(50);
}
}

You might also like