T12
void main()
{
unsigned char num;
unsigned char input;
unsigned char keypad[]={0,1,2,3,0,
4,5,6,0,
7,8,9,0,
0,0,0,0};
unsigned int kp,i;
TRISC=0;
TRISD=0xFF;
Lcd_Init(&PORTC);
Keypad_Init(&PORTD);
Lcd_Cmd(LCD_CURSOR_OFF);
Lcd_Cmd(LCD_CLEAR);
Lcd_Out(1,1,"Enter number");
for(i=0;i<2;i++)
{
while(!Keypad_Read());
kp=Keypad_Read();
num=num*10*i+keypad[kp];
Lcd_Chr(2,i+1,keypad[kp]+48);
while(Keypad_Read());
}
while(Keypad_Read()!=15);
Return:Lcd_Cmd(LCD_CLEAR);
Lcd_Out(1,1,"What is number?");
while(Keypad_Read());
for(i=0;i<2;i++)
{
while(!Keypad_Read());
kp=Keypad_Read();
input=input*10*i+keypad[kp];
Lcd_Chr(2,i+1,keypad[kp]+48);
while(Keypad_Read());
}
while(Keypad_Read()!=15);
Lcd_Cmd(LCD_CLEAR);
while(Keypad_Read());
if(num>input)
{
Lcd_Out(1,1,"More than!");
while(Keypad_Read()!=15);
goto Return;
}
else if(num<input)
{
Lcd_Out(1,1,"Less than!");
while(Keypad_Read()!=15);
goto Return;
}
else
{
Lcd_Out(1,1,"Correct");
}
}
ความคิดเห็น
แสดงความคิดเห็น