1.参考书P121 数码管轮流显示0~F
#include 《mega16.h》
#include 《delay.h》
flash unsigned char led_7[16]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07, 0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71};
flash unsigned char position[8]={ 0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
void main(void)
{
unsigned char i=0,j=0;
PORTA=0x00; // 显示控制I/O端口初始化
DDRA=0xFF;
PORTC=0xFF;
DDRC=0xFF;
while(1)
{
for(i=0;i《=7;i++)
{
PORTC=position[i];
for(j=0;j《16;j++)
{
PORTA=led_7[j];
delay_ms(500);
}
}
};
}
用定时器实现数码管轮流显示0~F
#include 《mega16.h》
flash unsigned char led_7[17]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71,0x00};
flash unsigned char position[8]={ 0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char disbuff[8]; // 显示缓冲区,存放要显示的8个字符的段码值
unsigned char posit,time_counter;
bit time_500ms_ok;
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
全部0条评论
快来发表一下你的评论吧 !