zoukankan      html  css  js  c++  java
  • avrstudio 5 同时点亮8只数码管

    avrstudio 5开发程序:

    备注:

       1.在proteus的里面可以导入elf文件,来实现也就是说不一定非要生成hex文件

       2.关键点:是要消影子,这点在原来的书上是没有的,可能是编书时的错漏。

    源代码:

    /*
    * eight_led_return.c
    * Project: eight led
    * Created: 2011-3-25 12:23:09
    * Author : xmphoenix.fish
    */
    #include <avr/io.h>
    #include<util/delay.h>
    #define F_CPU 8000000UL
    //led light char
    const char table[]={0xC0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};

    int main(void)
    {
        char i;
        DDRE= 0xff;DDRF = 0xff;//set the port c and d for input
        PORTF=0x01;

        while(1)
        {
            //TODO:: Please write your application code
            for (i=0;i<8;i++)
            {
                PORTF=_BV(i);//the operation _BV() contain in system
                PORTE=table[i];
                _delay_us(2);//strip the false figure
                PORTF=0x00;
                PORTE=0xff;
                _delay_us(2);
            }
        }
        return 0;
    }

    截图:

    2011-3-25-12-55

  • 相关阅读:
    [栈]
    [数据结构实验]学生成绩管理
    [数据结构实验]集合交并
    shapefile 转 geojson 文件类型
    ubuntu sublime text key
    opengl
    c++
    sublime text3 key
    ubuntu安装nvidia驱动
    全球国家svg边界svg
  • 原文地址:https://www.cnblogs.com/xmphoenix/p/1995292.html
Copyright © 2011-2022 走看看