mega16完全就可以驱动了,没必要再加驱动,另外你的驱动也就相当于uln2003吧,给你一个可行的程序你试试
#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar SEG7[10]={/*0x3f,0x06, 0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F*/
0x3F,/*0*/
0x06,/*1*/
0x5B,/*2*/
0x4F,/*3*/
0x66,/*4*/
0x6D,/*5*/
0x7D,/*6*/
0x07,/*7*/
0x7F,/*8*/
0x6F,/*9*/
};
uchar ACT[2]={0x01,0x02};
void delay_ms(uint k)
{
uint i,j;
for(i=0;i
for(j=0;j<570;j++)
;
}
}
void main(void)
{
uchar i,count;
DDRA=0xff;
DDRC=0xff;
DDRD=0x00;
PORTA=0x00;
PORTC=0xff;
PORTD=0xff;
while(1)
{
if((PIND&0x10)==0)
{
delay_ms(1);
if((PIND&0x10)==0) //防止键盘抖动
if(count<99)
count++;
}
if((PIND&0x20)==0)
{
delay_ms(1);
if((PIND&0x20)==0) //防止键盘抖动
if(count>0)
count--;
}
for(i=0;i<100;i++)
{ PORTC=ACT[0];
PORTA=SEG7[count%10];
delay_ms(1);
PORTC=ACT[1];
PORTA=SEG7[count/10];
delay_ms(1);
}
/*count++;
if(count>99)count=0;*/
}
}