您的位置:首页单片机AVR单片机
内容搜索:
阅读内容
背景:#EDF0F5 #FAFBE6 #FFF2E2 #FDE6E0 #F3FFE1 #DAFAF3 #EAEAEF 默认  

ICCAVR学习小程序

[日期:2008-01-11 ] [来源: 作者:] [字体: (投递新闻)
#include <iom16v.h>
#include <macros.h>

/* This seems to produce the right amount of delay for the LED to 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);
    }
}
阅读:
录入:JETTA

推荐 】 【 打印
本文评论
      全部评论
发表评论


点评: 字数
姓名:
站长推荐