先上图
可以发现,Y6C控制数码管的位选,决定哪一位的数码管亮;而Y7C控制数码管的段选,且数码管为共阳极数码管。那么,我们就可以编写数码管模块了
#include "seg.h"
void Seg_Tran(uchar* seg_data,uchar* seg_code)
{
uchar i,j=0,temp;
for(i=0;i<8;i++,j++)
{
switch(seg_data[j])
{
case '0': temp = 0xc0;break;
case '1': temp = 0xf9;break;
case '2': temp = 0xa4;break;
case '3': temp = 0xb0;break;
case '4': temp = 0x99;break;
case '5': temp = 0x92;break;
case '6': temp = 0x82;break;
case '7': temp = 0xf8;break;