找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 10342|回复: 9
收起左侧

74HC595驱动3位数码管 原理图PCB封装库+STM32和51单片机代码

  [复制链接]
ID:379212 发表于 2018-11-21 17:01 | 显示全部楼层 |阅读模式
ST32和51单片机控制74HC595Q驱动3位数码管资料_驱动代码+原理图+原理图库+封装库
1542790420(1).png 1542790468(1).png

Altium Designer画的原理图和PCB图封装库如下:(51hei附件中可下载工程文件)
0.png 0.png 0.png

单片机源程序如下:
  1. //2位数码管测试代码           
  2. //樊川技术
  3. //http://shop342679635.taobao.com
  4. //实验现象:3位数码管轮流显示数码管编码表里面的字符
  5. #include "led.h"
  6. #include "delay.h"
  7. #include "sys.h"
  8. #include "HC595.h"

  9. unsigned char Qian_Wei,Bai_Wei,Shi_Wei,Ge_Wei;        //千位,百位,十位,个位

  10. //数码管编码
  11. unsigned char table[] =
  12. {0xc0,0xf9,0xa4,0xb0,0x99,
  13. 0x92,0x82,0xf8,0x80,0x90,
  14. 0xff,0x00,0x90,0x86,0xaf,
  15. 0xc0,0x89,0xc7,0x8e,0xc1,0x7f};
  16. //0,1,2,3,4,5,6,7,8,9,全暗,全亮,g,E,r,O,H,L,F,U,小数点,共阳数码管使用


  17. int main(void)
  18. {
  19.         int a, b, c, d;
  20.         a = 0;//这些常量置0,否则后面显示会出问题
  21.         b = 0;
  22.         c = 0;
  23.         d = 0;
  24.         SystemInit();                                        //系统时钟初始化为72M          SYSCLK_FREQ_72MHz
  25.         delay_init(72);                                //延时函数初始化
  26.         NVIC_Configuration();        //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
  27.         LED_Init();                                                //LED端口初始化
  28.         HC595_Init();
  29.         
  30.         //清空LED数码管
  31.         Bai_Wei = table[10];//清空LED
  32.         Shi_Wei = table[10];//清空LED
  33.         Ge_Wei = table[10];//清空LED
  34.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  35.         delay_ms(3000);
  36.         
  37.         //依次测试百位至个位全亮
  38.         Bai_Wei = table[11];//百位全亮
  39.         Shi_Wei = table[10];//清空LED
  40.         Ge_Wei = table[10];//清空LED
  41.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  42.         delay_ms(2000);
  43.         Bai_Wei = table[10];//清空LED
  44.         Shi_Wei = table[11];//十位全亮
  45.         Ge_Wei = table[10];//清空LED
  46.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  47.         delay_ms(2000);
  48.         Bai_Wei = table[10];//清空LED
  49.         Shi_Wei = table[10];//清空LED
  50.         Ge_Wei = table[11];//个位全亮
  51.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  52.         delay_ms(2000);
  53.         
  54.         //同时显示0~9
  55.         Bai_Wei = table[0];
  56.         Shi_Wei = table[0];
  57.         Ge_Wei = table[0];
  58.         HC595_Display(Bai_Wei, Shi_Wei, Ge_Wei);
  59.         delay_ms(2000);
  60.         Bai_Wei = table[1];
  61.         Shi_Wei = table[1];
  62.         Ge_Wei = table[1];
  63.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  64.         delay_ms(2000);
  65.         Bai_Wei = table[2];
  66.         Shi_Wei = table[2];
  67.         Ge_Wei = table[2];
  68.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  69.         delay_ms(2000);
  70.         Bai_Wei = table[3];
  71.         Shi_Wei = table[3];
  72.         Ge_Wei = table[3];
  73.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  74.         delay_ms(2000);
  75.         Bai_Wei = table[4];
  76.         Shi_Wei = table[4];
  77.         Ge_Wei = table[4];
  78.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  79.         delay_ms(2000);
  80.         Bai_Wei = table[5];
  81.         Shi_Wei = table[5];
  82.         Ge_Wei = table[5];
  83.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  84.         delay_ms(2000);
  85.         Bai_Wei = table[6];
  86.         Shi_Wei = table[6];
  87.         Ge_Wei = table[6];
  88.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  89.         delay_ms(2000);
  90.         Bai_Wei = table[7];
  91.         Shi_Wei = table[7];
  92.         Ge_Wei = table[7];
  93.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  94.         delay_ms(2000);
  95.         Bai_Wei = table[8];
  96.         Shi_Wei = table[8];
  97.         Ge_Wei = table[8];
  98.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  99.         delay_ms(2000);
  100.         Bai_Wei = table[9];
  101.         Shi_Wei = table[9];
  102.         Ge_Wei = table[9];
  103.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  104.         delay_ms(2000);
  105.         HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
  106.         delay_ms(2000);
  107.         
  108.         while(1)
  109.         {               
  110.                 LED0=0;                                                        //这里使用了位带操作,也可以使用 GPIO_ResetBits(GPIOA,GPIO_Pin_8);
  111.                 delay_ms(20);                 
  112.                 LED0=1;                                                        //也可以使用          GPIO_SetBits(GPIOA,GPIO_Pin_8);                           
  113.                 delay_ms(20);                        

  114.                 a++;
  115.                 if(a==1)
  116.                 {
  117.                         a = 0;
  118.                         b++;
  119.                 }
  120.                 if(b == 10)
  121.                 {
  122.                         b = 0;
  123.                          c++;
  124.                 }
  125.                 if(c == 10)
  126.                 {
  127.                         c = 0;
  128.                         d++;                        
  129.                 }
  130.                 if(d == 10)d= 0;
  131.                 Bai_Wei = table[d];
  132.                 Shi_Wei = table[c];
  133.                 Ge_Wei = table[b];
  134.                 HC595_Display(Bai_Wei,Shi_Wei,Ge_Wei);
  135.                 //delay_ms(100);
  136.         }
  137. }
复制代码

所有资料51hei提供下载:
3位数码管资料_驱动代码+原理图+原理图库+封装库+PCB定位孔.rar (475.06 KB, 下载次数: 387)

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

ID:302042 发表于 2019-11-11 16:07 | 显示全部楼层
很好很好学习
回复

使用道具 举报

ID:618102 发表于 2019-11-28 17:40 | 显示全部楼层
很好的资料,对初学者很有帮助。。。
回复

使用道具 举报

ID:615721 发表于 2020-1-6 10:57 | 显示全部楼层
谢谢分享!
回复

使用道具 举报

ID:587012 发表于 2020-2-26 16:10 | 显示全部楼层
谢谢无私的分享!
回复

使用道具 举报

ID:697493 发表于 2020-5-27 18:50 | 显示全部楼层
很好的资料
回复

使用道具 举报

ID:815528 发表于 2020-8-24 10:52 来自手机 | 显示全部楼层
谢谢分享我,很好的资料
回复

使用道具 举报

ID:257260 发表于 2021-1-6 13:40 | 显示全部楼层

很好的资料,对初学者很有帮助。。。
回复

使用道具 举报

ID:81138 发表于 2021-1-25 23:31 来自手机 | 显示全部楼层
谢谢分享楼主,很好的资料
回复

使用道具 举报

ID:81138 发表于 2021-1-27 15:54 | 显示全部楼层
准被移植到STM8上
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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