接上线没反应,按键按了一个灯都不亮。单片机是九齐NY8050D,0 1 2 5为LED 4是按键
unsigned char ID;void delay(unsigned long num)
{
while(num--);
}
void main()
{
unsigned long delay_time= 1000;
BPHCON = (unsigned char)~(C_PB4_PHB|C_PB0_PHB|C_PB1_PHB|C_PB2_PHB |C_PB3_PHB|C_PB5_PHB);//0 1 2 3 4 5 设置位上拉
IOSTB =IOSTB | C_PB3_Input ; // pb3 只能输入
IOSTB =IOSTB | C_PB4_Input ; // pb4 输入
IOSTB =IOSTB & (~(C_PB0_Input| C_PB1_Input|C_PB2_Input|C_PB5_Input));// 设置pb1 2 05 输出
PB1=0;
PB2=0;
PB0=0;
PB5=0;
while(1)
{
if(PB4==0)
{
delay_time;
if(PB4==0)
{
ID++;
if(ID==4)
{
ID=0;
}
while(PB4==0);
}
}
switch(ID)
{
case 0:
PB0=~PB0;
delay_time;
break;
case 1:
PB1=~PB1;
delay_time;
break;
case 2:
PB2=~PB2;
delay_time;
break;
case 3:
PB5=~PB5;
delay_time;
break;
}
}
} 兄弟还在玩九齐050吗?
页:
[1]