ICCAVR学习小程序

【ICCAVR学习小程序】 #include #include /* This seEMSto produce the right amount of delay for theLEDto be * seen */ void Delay() { unsigned char a, b; for (a = 1; a; a++) for (b = 1; b; b++) ; } void LED_On(int i) { PORTB = ~BIT(i);/* l...

【ICCAVR学习小程序】#include
#include

/* This seEMSto produce the right amount of delay for theLEDto be
* seen
*/

void Delay() {
unsigned char a, b;









for (a = 1; a; a++)
for (b = 1; b; b++)
;
}
void LED_On(int i) {
PORTB = ~BIT(i);/* low output to turn LED on */
Delay();
}
void main() {
int i;
DDRB = 0xFF;/* output */
PORTB = 0xFF;/* all off */while (1) {
/* forward march */
for (i = 0; i < 8; i++)
LED_On(i);
/* backward march */
for (i = 8; i > 0; i--)
LED_On(i);
/* skip */
for (i = 0; i < 8; i += 2)
LED_On(i);
for (i = 7; i > 0; i -= 2)
LED_On(i);
}
}


    推荐阅读