微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > AVR数码管扫描

AVR数码管扫描

时间:11-24 来源:互联网 点击:
#include avr/io.h>

#define uchar unsigned char
#define uint unsigned int
uchar display[] = { 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
uchar slice[] = { 0x70,0xb0,0xd0,0xe0};
int main(void)

{
uchar temp=0,tempb;
uint i;

DDRD &= ~(1<7);
PORTD |= (1 < 7);//打开上啦电阻
DDRB = 0xff;//设置为输出
DDRA = 0xf0;//设置为输出
tempb = PIND;

while(1)
{

for(temp=0;temp<4;temp++)
{
PORTA = slice[temp];
PORTB =display[temp];
for(tempb=0;tempb<200;tempb++)
for(i=0;i<2000;i++);
}
}
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top