PDA

View Full Version : سوال: مشکل این برنامه که برای PIC16f877A نوشته شده چی؟



franchesco
سه شنبه 06 مهر 1389, 12:22 عصر
مشکل این برنامه که برای PIC16f877A نوشته شده چی؟



char *text = "MICROPRO. BASED OS";
char *text2 = "Processing Job ";
unsigned char *inp;

void ledoutput(unsigned char led)
{
PORTA =led;

}

void lcdoutput(unsigned char lcd)
{ Lcd_Cmd(Lcd_CLEAR);
Lcd_Out(2, 2, text2);
Delay_ms(50);
Lcd_Cmd(Lcd_CLEAR);
Lcd_Chr(2,19,lcd);
Delay_ms(50);

}


//Function used to check the input coming from Keypad Input
unsigned char checkInput()
{



if(PORTB==0x10) //1
{
return '1';
}
else if(PORTB==0x11) //2
{
return '2' ;
}
else if(PORTB==0x12) //3
{
return '3' ;
}
else if(PORTB==0x14) //4
{
return'4' ;
}
else if(PORTB==0x15) //5
{
return'5' ;
}
else if(PORTB==0x16) //6
{
return'6' ;
}
else if(PORTB==0x18) //7
{
return '7' ;
}
else if(PORTB==0x19) //8
{
return '8' ;
}
else if(PORTB==0x1A) //9
{
return '9' ;
}
else if(PORTB==0x1C) // *
{
return '*' ;
}
else if(PORTB==0x1E) // #
{
return '#' ;
}
else if(PORTB==0x1d) //0
{
return '0' ;
}
PORTA = 0x00;


}

void initializing()
{
TRISA = 0x00; //Set Port A as Output for Led
TRISB = 0xff; //Set Port B as Output for LCD
TRISC = 0x00; //Set Port C as Input for Keypad

Lcd_Init(&PORTC); // Initialize LCD connected to PORTB
Lcd_Cmd(Lcd_CLEAR); // Clear display
Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off


Lcd_Out(2, 2, text); // Display text
Lcd_Out(3, 8, "******"); // Display asterisk
Delay_ms(500); // Delay 500 milliSeconds
Lcd_Cmd(Lcd_CLEAR);
Lcd_Out(2, 2, "Enter Job #: ");

}




void main()
{
unsigned char value;
initializing();

while(1)
{
value=checkInput(); // Call checkInput function
lcdoutput(value);
ledoutput(value);

}

}
//-------------------------------------------------------------