|
ST32和51單片機(jī)控制74HC595Q驅(qū)動(dòng)3位數(shù)碼管資料_驅(qū)動(dòng)代碼+原理圖+原理圖庫(kù)+封裝庫(kù)
1542790420(1).png (7.11 KB, 下載次數(shù): 98)
下載附件
2018-11-21 16:57 上傳
1542790468(1).png (43.8 KB, 下載次數(shù): 62)
下載附件
2018-11-21 16:57 上傳
Altium Designer畫的原理圖和PCB圖封裝庫(kù)如下:(51hei附件中可下載工程文件)
0.png (6.02 KB, 下載次數(shù): 67)
下載附件
2018-11-21 17:42 上傳
0.png (16.56 KB, 下載次數(shù): 58)
下載附件
2018-11-21 17:42 上傳
0.png (8.18 KB, 下載次數(shù): 71)
下載附件
2018-11-21 17:42 上傳
單片機(jī)源程序如下:
- //2位數(shù)碼管測(cè)試代碼
- //樊川技術(shù)
- //http://shop342679635.taobao.com
- //實(shí)驗(yàn)現(xiàn)象:3位數(shù)碼管輪流顯示數(shù)碼管編碼表里面的字符
- #include "led.h"
- #include "delay.h"
- #include "sys.h"
- #include "HC595.h"
- unsigned char Qian_Wei,Bai_Wei,Shi_Wei,Ge_Wei; //千位,百位,十位,個(gè)位
- //數(shù)碼管編碼
- unsigned char table[] =
- {0xc0,0xf9,0xa4,0xb0,0x99,
- 0x92,0x82,0xf8,0x80,0x90,
- 0xff,0x00,0x90,0x86,0xaf,
- 0xc0,0x89,0xc7,0x8e,0xc1,0x7f};
- //0,1,2,3,4,5,6,7,8,9,全暗,全亮,g,E,r,O,H,L,F,U,小數(shù)點(diǎn),共陽(yáng)數(shù)碼管使用
- int main(void)
- {
- int a, b, c, d;
- a = 0;//這些常量置0,否則后面顯示會(huì)出問(wèn)題
- b = 0;
- c = 0;
- d = 0;
- SystemInit(); //系統(tǒng)時(shí)鐘初始化為72M SYSCLK_FREQ_72MHz
- delay_init(72); //延時(shí)函數(shù)初始化
- NVIC_Configuration(); //設(shè)置NVIC中斷分組2:2位搶占優(yōu)先級(jí),2位響應(yīng)優(yōu)先級(jí)
- LED_Init(); //LED端口初始化
- HC595_Init();
-
- //清空LED數(shù)碼管
- Bai_Wei = table[10];//清空LED
- Shi_Wei = table[10];//清空LED
- Ge_Wei = table[10];//清空LED
- HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
- delay_ms(3000);
-
- //依次測(cè)試百位至個(gè)位全亮
- Bai_Wei = table[11];//百位全亮
- Shi_Wei = table[10];//清空LED
- Ge_Wei = table[10];//清空LED
- HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
- delay_ms(2000);
- Bai_Wei = table[10];//清空LED
- Shi_Wei = table[11];//十位全亮
- Ge_Wei = table[10];//清空LED
- HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
- delay_ms(2000);
- Bai_Wei = table[10];//清空LED
- Shi_Wei = table[10];//清空LED
- Ge_Wei = table[11];//個(gè)位全亮
- HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
- delay_ms(2000);
-
- //同時(shí)顯示0~9
- Bai_Wei = table[0];
- Shi_Wei = table[0];
- Ge_Wei = table[0];
- HC595_Display(Bai_Wei, Shi_Wei, Ge_Wei);
- delay_ms(2000);
- Bai_Wei = table[1];
- Shi_Wei = table[1];
- Ge_Wei = table[1];
- HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
- delay_ms(2000);
- Bai_Wei = table[2];
- Shi_Wei = table[2];
- Ge_Wei = table[2];
- HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
- delay_ms(2000);
- Bai_Wei = table[3];
- Shi_Wei = table[3];
- Ge_Wei = table[3];
- HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
- delay_ms(2000);
- Bai_Wei = table[4];
- Shi_Wei = table[4];
- Ge_Wei = table[4];
- HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
- delay_ms(2000);
- Bai_Wei = table[5];
- Shi_Wei = table[5];
- Ge_Wei = table[5];
- HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
- delay_ms(2000);
- Bai_Wei = table[6];
- Shi_Wei = table[6];
- Ge_Wei = table[6];
- HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
- delay_ms(2000);
- Bai_Wei = table[7];
- Shi_Wei = table[7];
- Ge_Wei = table[7];
- HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
- delay_ms(2000);
- Bai_Wei = table[8];
- Shi_Wei = table[8];
- Ge_Wei = table[8];
- HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
- delay_ms(2000);
- Bai_Wei = table[9];
- Shi_Wei = table[9];
- Ge_Wei = table[9];
- HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
- delay_ms(2000);
- HC595_Display(Bai_Wei, Shi_Wei,Ge_Wei);
- delay_ms(2000);
-
- while(1)
- {
- LED0=0; //這里使用了位帶操作,也可以使用 GPIO_ResetBits(GPIOA,GPIO_Pin_8);
- delay_ms(20);
- LED0=1; //也可以使用 GPIO_SetBits(GPIOA,GPIO_Pin_8);
- delay_ms(20);
- a++;
- if(a==1)
- {
- a = 0;
- b++;
- }
- if(b == 10)
- {
- b = 0;
- c++;
- }
- if(c == 10)
- {
- c = 0;
- d++;
- }
- if(d == 10)d= 0;
- Bai_Wei = table[d];
- Shi_Wei = table[c];
- Ge_Wei = table[b];
- HC595_Display(Bai_Wei,Shi_Wei,Ge_Wei);
- //delay_ms(100);
- }
- }
復(fù)制代碼
所有資料51hei提供下載:
3位數(shù)碼管資料_驅(qū)動(dòng)代碼+原理圖+原理圖庫(kù)+封裝庫(kù)+PCB定位孔.rar
(475.06 KB, 下載次數(shù): 388)
2018-11-21 17:44 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
評(píng)分
-
查看全部評(píng)分
|