c语言编写程序,将led从左往右,再从右往左依次往返点亮 5
展开全部
流水灯程序是keil的自带例子,你直接跑就是。
void wait (void) { /* wait function */
; /* only to delay for LED flashes */
}
void main (void) {
unsigned int i; /* Delay var */
unsigned char j; /* LED var */
while (1) { /* Loop forever */
for (j=0x01; j< 0x80; j<<=1) { /* Blink LED 0, 1, 2, 3, 4, 5, 6 */
P1 = j; /* Output to LED Port */
for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */
wait (); /* call wait function */
}
}
for (j=0x80; j> 0x01; j>>=1) { /* Blink LED 6, 5, 4, 3, 2, 1 */
P1 = j; /* Output to LED Port */
for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */
wait (); /* call wait function */
}
}
}
}
闪烁你可以再加几行。
void wait (void) { /* wait function */
; /* only to delay for LED flashes */
}
void main (void) {
unsigned int i; /* Delay var */
unsigned char j; /* LED var */
while (1) { /* Loop forever */
for (j=0x01; j< 0x80; j<<=1) { /* Blink LED 0, 1, 2, 3, 4, 5, 6 */
P1 = j; /* Output to LED Port */
for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */
wait (); /* call wait function */
}
}
for (j=0x80; j> 0x01; j>>=1) { /* Blink LED 6, 5, 4, 3, 2, 1 */
P1 = j; /* Output to LED Port */
for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */
wait (); /* call wait function */
}
}
}
}
闪烁你可以再加几行。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询