c语言数码管显示循环右移
时间:10-02
整理:3721RD
点击:
#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define LEDdata P0
sbit cs1=P3^6;
sbit cs2=P3^7;
uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar buf[8]={7,6,5,4,3,2,1,0};
void delay(uint i)
{
while(--i);
}
void display()
{
uchar i,j=0x80;
for(i=0;i<8;i++)
{
cs1=1;cs2=0;
LEDdata=table[buf[i]];
cs1=0;cs2=1;
P2=j;
delay(100);
j=_cror_(j,1);
cs1=cs2=0;
LEDdata=0xff;
}
}
void main()
{
while(1)
{
display();
}
}
想让数码管循环右移01234567、循环右移。大神们指导下小弟。最好说下思路,编写的思路。
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define LEDdata P0
sbit cs1=P3^6;
sbit cs2=P3^7;
uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar buf[8]={7,6,5,4,3,2,1,0};
void delay(uint i)
{
while(--i);
}
void display()
{
uchar i,j=0x80;
for(i=0;i<8;i++)
{
cs1=1;cs2=0;
LEDdata=table[buf[i]];
cs1=0;cs2=1;
P2=j;
delay(100);
j=_cror_(j,1);
cs1=cs2=0;
LEDdata=0xff;
}
}
void main()
{
while(1)
{
display();
}
}
想让数码管循环右移01234567、循环右移。大神们指导下小弟。最好说下思路,编写的思路。