AVR 单片机实现流水灯
/******************************************************************************
I/O 口输出实验-流水灯
*************************************************************************/
#include <iom16v.h>
/******************************************************************************
延时函数
函数说明:软件延时函数,此函数延时单位约为 1mS。
晶振频率:CPU 内部 1M 晶振。
带入参数:i 无符号整型,变量范围:0-65535。
返回参数:无
*******************************************************************************
**************/
void delay_ms(unsigned int i) {
unsigned int a;
unsigned char b;
for (a = 0; a < i; a++) {
for (b = 1; b; b++) {
;
}
}
}
/
*******************************************************************************
**************
主函数
*******************************************************************************
**************/
void main(void) {
unsigned char i;
DDRA = 0x00; /*方向输入*/
PORTA = 0xFF; /*打开上拉*/
DDRB = 0xFF; /*方向输出*/
PORTB = 0xFF; /*高电平*/
DDRC = 0x00;
PORTC = 0xFF;
DDRD = 0x00;
PORTD = 0xFF;
评论0
最新资源