งาน17
void main()
{
unsigned char rcw,rccw;
unsigned char step_cw[]={0x01,0x02,0x04,0x08};
unsigned char step_ccw[]={0x04,0x02,0x01,0x08};
unsigned char keypad[]={0,1,2,3,0,
4,5,6,0,
7,8,9,0,
0,0,0,0};
unsigned char i,m,kp;
TRISB=0;
TRISC=0;
TRISD=0xFF;
Lcd_Init(&PORTB);
Keypad_Init(&PORTD);
Lcd_Cmd(LCD_CURSOR_OFF);
Return:Lcd_Cmd(LCD_CLEAR);
Lcd_Out(1,1,"Rotate CW?");
while(!Keypad_Read());
kp=Keypad_Read();
rcw=keypad[kp];
Lcd_Chr(2,1,keypad[kp]+48);
while(Keypad_Read());
while(Keypad_Read()!=15);
while(Keypad_Read());
Lcd_Cmd(LCD_CLEAR);
Lcd_Out(1,1,"Rotate CCW?");
while(!Keypad_Read());
kp=Keypad_Read();
rccw=keypad[kp];
Lcd_Chr(2,1,keypad[kp]+48);
while(Keypad_Read());
while(Keypad_Read()!=15);
while(Keypad_Read());
Lcd_Cmd(LCD_CLEAR);
Lcd_Out(1,1,"Rotating...");
for(i=0;i<rcw;i++)
{
while(m<4)
{
PORTC=step_cw[m];
delay_ms(500);
m++;
}
m=0;
}
for(i=0;i<rccw;i++)
{
while(m<4)
{
PORTC=step_ccw[m];
delay_ms(500);
m++;
}
m=0;
}
goto Return;
}
void main()
{
unsigned char rcw,rccw;
unsigned char step_cw[]={0x01,0x02,0x04,0x08};
unsigned char step_ccw[]={0x04,0x02,0x01,0x08};
unsigned char keypad[]={0,1,2,3,0,
4,5,6,0,
7,8,9,0,
0,0,0,0};
unsigned char i,m,kp;
TRISB=0;
TRISC=0;
TRISD=0xFF;
Lcd_Init(&PORTB);
Keypad_Init(&PORTD);
Lcd_Cmd(LCD_CURSOR_OFF);
Return:Lcd_Cmd(LCD_CLEAR);
Lcd_Out(1,1,"Rotate CW?");
while(!Keypad_Read());
kp=Keypad_Read();
rcw=keypad[kp];
Lcd_Chr(2,1,keypad[kp]+48);
while(Keypad_Read());
while(Keypad_Read()!=15);
while(Keypad_Read());
Lcd_Cmd(LCD_CLEAR);
Lcd_Out(1,1,"Rotate CCW?");
while(!Keypad_Read());
kp=Keypad_Read();
rccw=keypad[kp];
Lcd_Chr(2,1,keypad[kp]+48);
while(Keypad_Read());
while(Keypad_Read()!=15);
while(Keypad_Read());
Lcd_Cmd(LCD_CLEAR);
Lcd_Out(1,1,"Rotating...");
for(i=0;i<rcw;i++)
{
while(m<4)
{
PORTC=step_cw[m];
delay_ms(500);
m++;
}
m=0;
}
for(i=0;i<rccw;i++)
{
while(m<4)
{
PORTC=step_ccw[m];
delay_ms(500);
m++;
}
m=0;
}
goto Return;
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น