[Atmel] 用AtmelStudio6.2跑mega16例程(18):点阵显示

[复制链接]
1077|0
 楼主| ddllxxrr 发表于 2014-9-19 23:06 | 显示全部楼层 |阅读模式
今天这个很好理解,大家自己就可看明白:

Proteus截图:




Atmel Studio 6.2程序:
  1. /*
  2. * GccApplication25.c
  3. *
  4. * Created: 2014-9-19 22:55:40
  5. *  Author: Administrator
  6. */


  7. #include <avr/io.h>
  8. #define uchar unsigned char
  9. #define uint unsigned int
  10. unsigned char tab1[]={0x00,0x36,0x36,0x36,0x49};
  11. unsigned char tab2[]={0x01,0x02,0x04,0x08,0x10};
  12. void delay(uint n)
  13. {
  14.         uint i;
  15.         for(i=0;i<n;i++);
  16. }
  17. int main(void)
  18. {
  19.         uchar j,t=0;
  20.         DDRC=0xFF;
  21.         PORTC=0xFF;
  22.         DDRD=0xFF;
  23.         PORTD=0xFF;
  24.         while(1)
  25.         {
  26.                 for(j=0;j<6;j++)
  27.                 {
  28.                         PORTD=tab2[t];
  29.                         PORTC=tab1[j];
  30.                         delay(555);
  31.                         t++;
  32.                         if(t==6)
  33.                         {
  34.                                 t=0;
  35.                                 PORTD=0x00;
  36.                         }
  37.                 }
  38.         }
  39. }


本帖子中包含更多资源

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

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

本版积分规则

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

2404

主题

7001

帖子

68

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