找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 11503|回復(fù): 9
收起左側(cè)

74HC595驅(qū)動3位數(shù)碼管 原理圖PCB封裝庫+STM32和51單片機代碼

  [復(fù)制鏈接]
ID:379212 發(fā)表于 2018-11-21 17:01 | 顯示全部樓層 |閱讀模式
ST32和51單片機控制74HC595Q驅(qū)動3位數(shù)碼管資料_驅(qū)動代碼+原理圖+原理圖庫+封裝庫
1542790420(1).png 1542790468(1).png

Altium Designer畫的原理圖和PCB圖封裝庫如下:(51hei附件中可下載工程文件)
0.png 0.png 0.png

單片機源程序如下:
  1. //2位數(shù)碼管測試代碼           
  2. //樊川技術(shù)
  3. //http://shop342679635.taobao.com
  4. //實驗現(xiàn)象:3位數(shù)碼管輪流顯示數(shù)碼管編碼表里面的字符
  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. //數(shù)碼管編碼
  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,小數(shù)點,共陽數(shù)碼管使用


  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();                                        //系統(tǒng)時鐘初始化為72M          SYSCLK_FREQ_72MHz
  25.         delay_init(72);                                //延時函數(shù)初始化
  26.         NVIC_Configuration();        //設(shè)置NVIC中斷分組2:2位搶占優(yōu)先級,2位響應(yīng)優(yōu)先級
  27.         LED_Init();                                                //LED端口初始化
  28.         HC595_Init();
  29.         
  30.         //清空LED數(shù)碼管
  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. }
復(fù)制代碼

所有資料51hei提供下載:
3位數(shù)碼管資料_驅(qū)動代碼+原理圖+原理圖庫+封裝庫+PCB定位孔.rar (475.06 KB, 下載次數(shù): 388)


評分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

回復(fù)

使用道具 舉報

ID:302042 發(fā)表于 2019-11-11 16:07 | 顯示全部樓層
很好很好學(xué)習(xí)
回復(fù)

使用道具 舉報

ID:618102 發(fā)表于 2019-11-28 17:40 | 顯示全部樓層
很好的資料,對初學(xué)者很有幫助。。。
回復(fù)

使用道具 舉報

ID:615721 發(fā)表于 2020-1-6 10:57 | 顯示全部樓層
謝謝分享!
回復(fù)

使用道具 舉報

ID:587012 發(fā)表于 2020-2-26 16:10 | 顯示全部樓層
謝謝無私的分享!
回復(fù)

使用道具 舉報

ID:697493 發(fā)表于 2020-5-27 18:50 | 顯示全部樓層
很好的資料
回復(fù)

使用道具 舉報

ID:815528 發(fā)表于 2020-8-24 10:52 來自手機 | 顯示全部樓層
謝謝分享我,很好的資料
回復(fù)

使用道具 舉報

ID:257260 發(fā)表于 2021-1-6 13:40 | 顯示全部樓層

很好的資料,對初學(xué)者很有幫助。。。
回復(fù)

使用道具 舉報

ID:81138 發(fā)表于 2021-1-25 23:31 來自手機 | 顯示全部樓層
謝謝分享樓主,很好的資料
回復(fù)

使用道具 舉報

ID:81138 發(fā)表于 2021-1-27 15:54 | 顯示全部樓層
準(zhǔn)被移植到STM8上
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表