找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2827|回复: 0
打印 上一主题 下一主题
收起左侧

自己用仿真做了个小点阵 单片机新手第一次发帖,勿喷。

[复制链接]
跳转到指定楼层
楼主
自己用proteus仿真做了个小点阵,(没点阵模块),希望大家喜欢


51黑电子单片机源程序预览:
  1. #include<reg52.h>
  2. #include<intrins.h>

  3. #define uint unsigned int
  4. #define uchar unsigned char

  5. uchar code LED3[][8]={
  6. {0x3C,0x18,0x18,0x18,0x18,0x18,0x18,0x3C},
  7. {0x78,0x30,0x31,0x31,0x31,0x30,0x30,0x78},
  8. {0xF0,0x61,0x62,0x62,0x62,0x61,0x60,0xF0},
  9. {0xE0,0xC3,0xC4,0xC4,0xC4,0xC2,0xC1,0xE0},
  10. {0x80,0x0C,0x13,0x10,0x10,0x08,0x04,0x83},
  11. {0x00,0x19,0x26,0x20,0x20,0x10,0x09,0x06},
  12. {0x00,0x33,0x4C,0x40,0x40,0x21,0x12,0x0C},
  13. {0x00,0x66,0x99,0x81,0x81,0x42,0x24,0x18},
  14. {0x00,0xCC,0x32,0x02,0x02,0x84,0x48,0x30},
  15. {0x00,0x31,0xC9,0x09,0x09,0x11,0x21,0xC0},
  16. {0x00,0x63,0x93,0x13,0x13,0x23,0x43,0x81},
  17. {0x00,0xC6,0x26,0x26,0x26,0x46,0x87,0x03},
  18. {0x00,0x8C,0x4C,0x4C,0x4C,0x8C,0x0F,0x07},
  19. {0x00,0x19,0x99,0x99,0x99,0x19,0x1F,0x0F},
  20. {0x00,0x33,0x33,0x33,0x33,0x33,0x3F,0x1E},
  21. {0x00,0x66,0x66,0x66,0x66,0x66,0x3E,0x3C},
  22. {0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xFC,0x78}
  23. };// I LOVE YOU的动态显示
  24. uchar code table[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};//行数据

  25. sbit SH_CP=P2^0;
  26. sbit DS=P2^1;
  27. sbit ST_CP=P2^2;

  28.                  
  29. void delay(uint z);
  30. void write_dat(uchar date);


  31. int main(void)
  32. {
  33.         uint i,j,num;
  34.         while(1)
  35.         {  
  36.                 for(i=0;i<17;i++)
  37.                 {
  38.                         for(num=60;num>0;num--)
  39.                         for(j=0;j<8;j++)
  40.                         {
  41.                                 write_dat(table[j]);
  42.                                 P3=~LED3[i][j];
  43.                                 delay(80);
  44.                         }
  45.                 }
  46.                 }
  47. }

  48. void delay(uint z)
  49. {
  50.         while(z--);
  51. }

  52. void write_dat(uchar date)
  53. {                 
  54.         uchar i;
  55.         SH_CP=1;
  56.         for(i=0;i<8;i++)
  57.         {
  58.                 if(date&0x80)
  59.                 DS=1;
  60.                 else
  61.                 DS=0;
  62.                 date=date<<1;
  63.                 SH_CP=0;
  64.                 _nop_();_nop_();
  65.                 SH_CP=1;
  66.         }
  67.         ST_CP=0;
  68.         _nop_();_nop_();
  69.         ST_CP=1;

  70. }
复制代码


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表