关于四位共阴极七段数码管
unsigned char we[4] = {0xf7,0xfb,0xfd,0xfe};
unsigned int du[4];
void display()
{
unsigned char i;
unsigned int ge,shi,bai,qian;
qian = temp/1000;
bai = temp/100%10;
shi = temp%100/10;
ge = temp%100%10;
du[0] = table[ge];
du[1] = table[shi];
du[2] = table[bai];
du[3] = table[qian];
for(i=0;i<4;i++)
{
P0 = du[i];//段选
P1 = we[i];//位选
delayms(8);
P0 = 255;
}
}
有什么问题呢?
不管是共阴极数码管,还是共阳极数码管,只要数据对就能正常显示。你说的显示有些暗,估计是延时过快引起的,可适当把延时函数加大一些。
称重传感器的数据通过串口是正常的啊。难道需要把十六进制的转换成十进制再拆单位吗?
不要沉啊,,求解答
不要沉啊不要沉啊 跟着学习
自己顶一下。
最近又开始弄这个,亮度通过加三极管解决了,但是数据现在闪烁,用的是定时器中断来实现
void T0_init()
{
count = 0;
TMOD = 0x03;
TH0 = 253/8;
TL0 = 253%8;
TR0=1;
ET0=1;
}
void T0_inter() interrupt 1
{
unsigned char ge=0;
unsigned char shi=0;
unsigned char bai=0;
unsigned char qian = 0;
unsigned char temp ;
unsigned char j=0;
UN32 num;
num.DI=0;
temp = HX711_getdata()>>8;
temp = temp-b;
qian = temp/1000;
bai = temp/100%10;
shi = temp%100/10;
ge = temp%100%10;
du[3] = table[qian];
du[2] = table[bai];
du[1] = table[shi];
du[0] = table[ge];
count++;
if(count==1)
{
P0 = du[0];
P1 = we[0];
delayms(10);
}else if(count==2)
{
P0 = du[1];
P1 = we[1];
delayms(10);
}else if(count==3)
{
P0 = du[2];
P1 = we[2];
delayms(10);
count=0;
}
TH0 = 253/8;
TL0 = 253%8;
}
程序里程可以发给你