5路流水灯实验程序如下:
#define ALL_ON {PORTA&=0X1F;ORTC&=0XFC;}
#define ALL_OFF {PORTA|=~0X1F;ORTC|=~0XFC;}
#define LED1_ON PORTA&=0XDF
#define LED2_ON PORTA&=0XBF
#define LED3_ON PORTA&=0X7F
#define LED4_ON PORTC&=0XFD
#define LED5_ON PORTC&=0XFE
#define LED1_OFF PORTA|=~0XDF
#define LED2_OFF PORTA|=~0XBF
#define LED3_OFF PORTA|=~0X7F
#define LED4_OFF PORTC|=~0XFD
#define LED5_OFF PORTC|=~0XFE
void Gpio_Init(void)
{
DDRA|=0XE0;
PORTA&=0X1F;
DDRC|=0X03;
PORTC&=0XFC;
}
void led (void)
{
LED1_ON;
delay_nms(200);
LED2_ON;
delay_nms(200);
LED3_ON;
delay_nms(200);
LED4_ON;
delay_nms(200);
LED5_ON;
delay_nms(200);
LED1_OFF;
delay_nms(200);
LED2_OFF;
delay_nms(200);
LED3_OFF;
delay_nms(200);
LED4_OFF;
delay_nms(200);
LED5_OFF;
delay_nms(200);
}