[Atmel] 用AtmelStudio6.2跑mega16例程(27)0~9数码管显示

[复制链接]
 楼主| ddllxxrr 发表于 2014-10-5 21:23 | 显示全部楼层 |阅读模式
这个程序通过数码管显示0~9;中间加延时,感觉ATMEL STUDIO头文件太好了,几乎不用什么子程序。

以下是程序:

  1. /*
  2. * GccApplication11.c
  3. *
  4. * Created: 2014-10-5 21:02:02
  5. *  Author: Administrator
  6. */

  7. #define F_CPU 0x8000000UL
  8. #include <avr/io.h>
  9. #include <stdint.h>
  10. #include <util/delay.h>
  11. const int8_t display[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};

  12. int main(void)
  13. {
  14.     DDRC = 0xFF;
  15.         int8_t i=0;
  16.         while(1)
  17.     {
  18.         PORTC = display[i];
  19.                 i = (i+1)%10;
  20.                 _delay_ms(200);
  21.     }
  22. }

以下是仿真截图:



以下是Studio 6.2截图:




本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:http://shop34182318.taobao.com/ http://shop562064536.taobao.com

2403

主题

6994

帖子

68

粉丝
快速回复 在线客服 返回列表 返回顶部
个人签名:http://shop34182318.taobao.com/ http://shop562064536.taobao.com

2403

主题

6994

帖子

68

粉丝
快速回复 在线客服 返回列表 返回顶部