Mcuzone_xyz 发表于 2014-10-20 13:55 
最土的:用IO模拟嘛
#include<iot13Av.h>
#include<AVRdef.h>
/************延时**************/
void delay_ms(unsigned int i)
{
unsigned int a;
unsigned char b;
for (a = 0; a < i; a++)
{
for (b = 1; b; b++);
}
}
unsigned char n,k,e;
unsigned char x[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};/*共阳数码管段值*/
void clk_pb0(unsigned char m)
{
DDRB=0Xff;
PORTB=0Xff;
n=x[m];
for(e=0;e<8;e++)
{
k=n&0x01;
PORTB&=~BIT(0);
if(k=0)
{
PORTB&=~BIT(1);
}
if(k=1)
{
PORTB|=BIT(1);
}
PORTB|=BIT(0);
n>>=1;
}
}
void main()
{
while(1)
{
unsigned int l;
for(l=0;l<10;l++)
{
clk_pb0(l);
delay_ms(1000);
}
for(l=8;l>0;l++)
{
clk_pb0(l);
delay_ms(1000);
}
}
}
写了个ATTiny13的程序,为什么不亮的啊,线没接错,求解哪里出错了:L
|