單片機(jī)C語言程序設(shè)計(jì):8 只數(shù)碼管滾動(dòng)顯示數(shù)字、字符
/* 名稱:8 只數(shù)碼管滾動(dòng)顯示單個(gè)數(shù)字
說明:數(shù)碼管從左到右依次滾動(dòng)顯示
0~7,程序通過每次僅循環(huán)選通一只數(shù)碼
管
*/
#includereg51.h>
#includeintrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code DSY_CODE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
//延時(shí)
void DelayMS(uint x)
{
uchar t;
while(x--) for(t=0;t120;t++);
}
//主程序
void main()
{
}
uchar i,wei=0x80;
while(1)
{
for(i=0;i8;i++)
{
P2=0xff; //關(guān)閉顯示
wei=_crol_(wei,1);
P0=DSY_CODE[i];發(fā)送數(shù)字段碼
P2=wei; //發(fā)送位碼
DelayMS(300);
}
}
/* 名稱:8 只數(shù)碼管動(dòng)態(tài)顯示多個(gè)不同字符
說明:數(shù)碼管動(dòng)態(tài)掃描顯示 0~7。
*/
#includereg51.h>
#includeintrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code DSY_CODE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
c語言相關(guān)文章:c語言教程
評(píng)論