كود:
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
void Move_Delay() {
Delay_ms(500);
}
void WordToStr(unsigned input, char *output);
int sss;
int txt[8];
void main() {
Lcd_Init();
trisa=0;
trisd=0xff;
portd=0xff;
sss<=10000;
sss>=10;
sss=70;
lll:
if(rd0_bit=0)
sss=sss+20;
if(rd1_bit=0)
sss=sss-20;
while(rd2_bit==0){
Lcd_Out(1,1,"Forward");
Lcd_Out(2,1,"Delay");
WordToStr(sss, txt);
Lcd_Out(2,7,txt);
vdelay_MS(sss);
porta=0b00001000;
vdelay_MS(sss);
porta=0b00000100;
vdelay_MS(sss);
porta=0b00000010;
vdelay_MS(sss);
porta=0b00000001;
vdelay_MS(sss);
goto lll;
}
Lcd_Cmd(_LCD_CLEAR);
porta=0;
while(rd3_bit==0){
Lcd_Out(1,1,"Revers");
Lcd_Out(2,1,"Delay");
WordToStr(sss, txt);
Lcd_Out(2,7,txt);
vdelay_MS(sss);
porta=0b00000001;
vdelay_MS(sss);
porta=0b00000010;
vdelay_MS(sss);
porta=0b00000100;
vdelay_MS(sss);
porta=0b00001000;
vdelay_MS(sss);
goto lll;
}
porta=0;
Lcd_Cmd(_LCD_CLEAR);
goto lll;
pic 16f877
قمت باستخدام port b لlcd
,port a for motor
, port d for push button
وتبقى seven segement 2
اى مساعده من فضلكم