|
本程序采用八段共陰極數(shù)碼管顯示。程序及仿真見(jiàn)附件。
使用138譯碼器實(shí)現(xiàn)位選,74ls163實(shí)現(xiàn)段碼驅(qū)動(dòng)
程序思路:
1、添加位選及段選數(shù)組
uchar weixuan[] = {0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff};
uchar duanma[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40};
其中P3.3口為138譯碼器使能信號(hào),即0x08;將其與上位選碼即得到位選嗎數(shù)組
例:weixuan[1] = 0xf8 |0x01;
2、將輸入數(shù)字以個(gè)十百千萬(wàn)位分開,存入輸出數(shù)組;
output[3] = duanma[number/10000];
output[4] = duanma[number/1000%10];
output[5] = duanma[number/100%10];
output[6] = duanma[number/10%10];
output[7] = duanma[number%10];
3、利用for循環(huán)輸出,輸出過(guò)程為:
位選--段選--延時(shí)---消隱。
for(i=0;i<8;i++){
enable = weixuan[ i];
disp = output[ i];
delay(10);
disp = 0x00;
}
|
評(píng)分
-
查看全部評(píng)分
|