題目:在八位LED顯示器上滾動(dòng)顯示0、1、2、3、4、5、6、7、8、9、a、b、c、d、e、f, 且循環(huán)下去。
本文引用地址:http://m.butianyuan.cn/article/201611/320187.htm解決方案:(C語言編程)
#include
#include
#define uint unsigned int
#define uchar unsigned char
uchar sled_bit_table[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar sled_disp_buff[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,
0x83,0xc6,0xa1,0x86,0x8e,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
#define sled_dm_port P0
#define sled_wm_port P2
sbit speaker_en_port = P3^7;
void delay_1ms(uchar x)
{
uchar j;
while(x--){
for(j=0;j<125;j++)
{;}
}
}
void main()
{
uchar i;
uchar j;
uint count=0;
speaker_en_port = 0;
while(1){
for(j=0;j<100;j++){
for(i=0;i<8;i++){
sled_wm_port = 0xff;
sled_dm_port = sled_disp_buff[i+count];
sled_wm_port = sled_bit_table[i];
delay_1ms(1);
}
}
count++;
if(count>=24) count=0;
}
}
評論