21ic问答首页 - 普中单片机学习动态数码管
普中单片机学习动态数码管
忽而热2022-06-17
大佬,我想动态数码管对应位由0到7,再由7到0,一直循环,可是只能循环一次,这是那里的问题呢?void smg_display(void)
{
u8 i=0;
for(i=0;i<8;i++)
{
switch(i)
{
case 0: LSC=1;LSB=1;LSA=1;break;
case 1: LSC=1;LSB=1;LSA=0;break;
case 2: LSC=1;LSB=0;LSA=1;break;
case 3: LSC=1;LSB=0;LSA=0;break;
case 4: LSC=0;LSB=1;LSA=1;break;
case 5: LSC=0;LSB=1;LSA=0;break;
case 6: LSC=0;LSB=0;LSA=1;break;
case 7: LSC=0;LSB=0;LSA=0;break;
}
SMG_A_DP_PORT=gsmg_code[i];
delay_10us(100000);
SMG_A_DP_PORT=0X00;
}
for(i=7;i>=0;i--)//·´ÏòÊä³öfor(i=7;i>=0;i--)
{
switch(i)//λѡ
{
case 0: LSC=1;LSB=1;LSA=1;break;
case 1: LSC=1;LSB=1;LSA=0;break;
case 2: LSC=1;LSB=0;LSA=1;break;
case 3: LSC=1;LSB=0;LSA=0;break;
case 4: LSC=0;LSB=1;LSA=1;break;
case 5: LSC=0;LSB=1;LSA=0;break;
case 6: LSC=0;LSB=0;LSA=1;break;
case 7: LSC=0;LSB=0;LSA=0;break;
}
SMG_A_DP_PORT=gsmg_code[i];
delay_10us(100000);
SMG_A_DP_PORT=0X00;
}
}
void main()
{
SMG_A_DP_PORT=gsmg_code[0];
while(1)
{
smg_display();
}
}
{
u8 i=0;
for(i=0;i<8;i++)
{
switch(i)
{
case 0: LSC=1;LSB=1;LSA=1;break;
case 1: LSC=1;LSB=1;LSA=0;break;
case 2: LSC=1;LSB=0;LSA=1;break;
case 3: LSC=1;LSB=0;LSA=0;break;
case 4: LSC=0;LSB=1;LSA=1;break;
case 5: LSC=0;LSB=1;LSA=0;break;
case 6: LSC=0;LSB=0;LSA=1;break;
case 7: LSC=0;LSB=0;LSA=0;break;
}
SMG_A_DP_PORT=gsmg_code[i];
delay_10us(100000);
SMG_A_DP_PORT=0X00;
}
for(i=7;i>=0;i--)//·´ÏòÊä³öfor(i=7;i>=0;i--)
{
switch(i)//λѡ
{
case 0: LSC=1;LSB=1;LSA=1;break;
case 1: LSC=1;LSB=1;LSA=0;break;
case 2: LSC=1;LSB=0;LSA=1;break;
case 3: LSC=1;LSB=0;LSA=0;break;
case 4: LSC=0;LSB=1;LSA=1;break;
case 5: LSC=0;LSB=1;LSA=0;break;
case 6: LSC=0;LSB=0;LSA=1;break;
case 7: LSC=0;LSB=0;LSA=0;break;
}
SMG_A_DP_PORT=gsmg_code[i];
delay_10us(100000);
SMG_A_DP_PORT=0X00;
}
}
void main()
{
SMG_A_DP_PORT=gsmg_code[0];
while(1)
{
smg_display();
}
}
赞0
评论
2022-06-30
赞0
评论
2022-06-24
赞0
u8 i=0;
for(i=0;i<8;i++)
{
switch(i)
{
case 0: LSC=1;LSB=1;LSA=1;break;
case 1: LSC=1;LSB=1;LSA=0;break;
case 2: LSC=1;LSB=0;LSA=1;break;
case 3: LSC=1;LSB=0;LSA=0;break;
case 4: LSC=0;LSB=1;LSA=1;break;
case 5: LSC=0;LSB=1;LSA=0;break;
case 6: LSC=0;LSB=0;LSA=1;break;
case 7: LSC=0;LSB=0;LSA=0;break;
}
SMG_A_DP_PORT=gsmg_code[i];
delay_10us(100000);
SMG_A_DP_PORT=0X00;
}
for(i=0;i<8;i++)
{
switch(7-i)//λѡ
{
case 0: LSC=1;LSB=1;LSA=1;break;
case 1: LSC=1;LSB=1;LSA=0;break;
case 2: LSC=1;LSB=0;LSA=1;break;
case 3: LSC=1;LSB=0;LSA=0;break;
case 4: LSC=0;LSB=1;LSA=1;break;
case 5: LSC=0;LSB=1;LSA=0;break;
case 6: LSC=0;LSB=0;LSA=1;break;
case 7: LSC=0;LSB=0;LSA=0;break;
}
SMG_A_DP_PORT=gsmg_code[7-i];
delay_10us(100000);
SMG_A_DP_PORT=0X00;
}
}
void main()
{
SMG_A_DP_PORT=gsmg_code[0];
while(1)
{
smg_display();
}
}
评论
2022-06-23
您需要登录后才可以回复 登录 | 注册