单片机16*16点阵的资料可以显示汉字 很全
单片机16x16点阵原理图
单片机16x16点阵pcb
- #include <reg52.h>
- #include<intrins.h>
- typedef unsigned char uchar;
- typedef unsigned int uint;
- typedef unsigned long uint32;
- code uchar graph[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0xFF,0x1F,0xF8,0x0F,0xF0,0xCF,0xF3,0xCF,0xF3,0xCF,0xF3,0xCF,0xF3,0xCF,0xF3, /**0**/
- 0xCF,0xF3,0xCF,0xF3,0xCF,0xF3,0xCF,0xF3,0xCF,0xF3,0x0F,0xF0,0x1F,0xF8,0xFF,0xFF,
- 0x7F,0xFC,0x3F,0xFC,0x1F,0xFC,0x0F,0xFC,0x7F,0xFC,0x7F,0xFC,0x7F,0xFC,0x7F,0xFC, /**1**/
- 0x7F,0xFC,0x7F,0xFC,0x7F,0xFC,0x7F,0xFC,0x7F,0xFC,0x7F,0xFC,0x0F,0xE0,0x0F,0xE0,
- 0xFF,0xFF,0x1F,0xF8,0x0F,0xF0,0xCF,0xF3,0xFF,0xF3,0xFF,0xF3,0xFF,0xF1,0xFF,0xF8, /**2**/
- 0x7F,0xFC,0x3F,0xFF,0x9F,0xFF,0xCF,0xFF,0xCF,0xF3,0x0F,0xF0,0x1F,0xF8,0xFF,0xFF,
- 0xFF,0xFF,0x1F,0xF8,0x0F,0xF0,0xCF,0xF3,0xFF,0xF3,0xFF,0xF3,0xFF,0xF1,0xFF,0xF8, /**3**/
- 0xFF,0xFC,0xFF,0xF9,0xFF,0xF1,0xFF,0xF3,0xCF,0xF3,0x0F,0xF0,0x1F,0xF8,0xFF,0xFF,
- 0xFF,0xFF,0xBF,0xFD,0xDF,0xFC,0xDF,0xFC,0xCF,0xFC,0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,0xF0,0xC0,0xF6, /**航**/
- 0xDD,0xF6,0xD9,0xF6,0xD5,0xF6,0xD5,0xB6,0xDD,0xB6,0x5D,0xB7,0x55,0x8F,0xAE,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
- };
- /*********74LS154N端口定义**********/
- sbit ENLED = P0^0;
- sbit A = P0^4;
- sbit b = P0^3;
- sbit C = P0^2;
- sbit D = P0^1;
- /*********74HC595N端口定义**********/
- sbit DIN = P0^5; //SER
- sbit SHCP = P0^6; //SRCK
- sbit STCP = P0^7; //RCK
- uint counter = 0,speed = 200,T = 0;
- void delays(uint i)
- {
- while(i--);
- }
-
- uchar keyscan(void) //键盘扫描函数,使用行列反转扫描法
- {
- uchar cord_h,cord_l;//行列值中间变量
- P2=0xf0; //行线输出全为0
- cord_h=P2&0xf0; //读入行
- if(cord_h!=0xf0) //先检测有无按键按下
- {
- delays(1000); //去抖
- if(cord_h!=0xf0)
- {
- cord_h=P2&0xf0; //读入行
- P2=cord_h|0x0f; //输出当前行
- cord_l=P2&0x0f; //读入列
- return(cord_h+cord_l);//键盘最后组合码值
- }
- }
- return(0x00);
- }
-
- uint GongNeng()
- {
- uint keys,t;
- keys = keyscan();
- switch(keys)
- {
- case 0xEE:t = 1;T = 0; break; /* 1 */
- case 0xDE:t = 2;T = 192; break; /* 2 */
- case 0xBE:t = 3;T = 176; break; /* 3 */
- case 0x7E:t = 0; break; /* 0 */
- case 0xED:t = 4;T = 16; break; /* 4 */
- case 0xDD:t = 5;T = 192; break; /* 5 */
- case 0xBD:t = 6; break; /* 6 */
- case 0x7D:if(speed <=100)speed -= 10;if(speed >100 && speed <=300)speed -= 20;if(speed >300)speed -= 200;if(speed <=20) speed = 20;break; /*加速*/
- case 0xEB:t = 7; break; /* 7 */
- case 0xDB:t = 8; break; /* 8 */
- case 0xBB:t = 9; break; /* 9 */
- case 0x7B:if(speed <=200)speed += 20;if(speed >200 && speed <=1000)speed += 100;if(speed >1000)speed += 50;if(speed >=3000) speed = 3000;break; /*减速*/
- case 0xE7:t = 0; break;
- case 0xD7:t = 0; break;
- case 0xB7:t = 0; break;
- case 0x77:t = 0; break;
- }
- return t ;
- }
- /******************************************************************************
- * 函 数 名 : Write_Data_To_HC595
- * 描 述 : 写数据到74HC595
- * 输 入 : 无.
- * 返 回 : 无.
- *******************************************************************************/
- void Write_Data_To_HC595( uchar RowData )
- {
- uchar i;
- for( i = 0; i < 8; i++ )
- { /* 拉低74HC595存储寄存器时钟 */
- SHCP = 0; /* 拉低74HC595移位寄存器时钟 */
- RowData <<= 1; /* 数据右移,因为是大端模式 */
- DIN = CY;
- SHCP = 1; /* 时钟上升沿,数据移入74HC595 */
- }
- }
- void timer1_init()
- {
- TMOD |= 0x10;
- TMOD &= 0xdf;
- TH1 = 0xFC;
- TL1 = 0x67;
- TR1 = 1;
- }
- void int_init()
- {
- ET1 = 1;
- EA = 1;
- }
- void refresh_led()
- {
- static uchar j = 0;
- Write_Data_To_HC595( 0xFF );
- Write_Data_To_HC595( 0xFF );
- STCP = 1; /* 上升沿,将移位寄存器数据锁存到存储寄存器 */
- STCP = 0;
- switch(j)
- {
- case 0: A = 0;b = 0;C = 0;D = 0;break;
- case 1: A = 1;b = 0;C = 0;D = 0;break;
- case 2: A = 0;b = 1;C = 0;D = 0;break;
- case 3: A = 1;b = 1;C = 0;D = 0;break;
- case 4: A = 0;b = 0;C = 1;D = 0;break;
- case 5: A = 1;b = 0;C = 1;D = 0;break;
- case 6: A = 0;b = 1;C = 1;D = 0;break;
- case 7: A = 1;b = 1;C = 1;D = 0;break;
- case 8: A = 0;b = 0;C = 0;D = 1;break;
- case 9: A = 1;b = 0;C = 0;D = 1;break;
- case 10: A = 0;b = 1;C = 0;D = 1;break;
- case 11: A = 1;b = 1;C = 0;D = 1;break;
- case 12: A = 0;b = 0;C = 1;D = 1;break;
- case 13: A = 1;b = 0;C = 1;D = 1;break;
- case 14: A = 0;b = 1;C = 1;D = 1;break;
- case 15: A = 1;b = 1;C = 1;D = 1;break;
- default: break;
- }
- Write_Data_To_HC595( graph[ ( T+j )* 2 + 1 ] ); /* 先写高字节数据到595 */
- Write_Data_To_HC595( graph[ ( T+j )* 2 ] ); /* 后写低字节数据到595 */
- STCP = 1; /* 上升沿,将移位寄存器数据锁存到存储寄存器 */
- STCP = 0; /* 写入行号,超过7后,自动切换到下半屏显示 */
-
- if(15 == j++) j = 0;
-
-
- }
- main()
- {
- ENLED = 0;
- timer1_init();
- int_init();
- while(1);
-
- }
- void interrupt_timer1() interrupt 3
- {
- TH1 = 0xFC;
- TL1 = 0x67;
- counter++;
- if(counter == speed)
- {
- counter = 0;
- switch(GongNeng())
- {
- case 0:{T += 0;} break;
- case 1:{T += 16;if(T >= 176){T= 0;}}break;
- case 2:{T += 16;if(T >= 208){T=192;}}break;
- case 3:{T += 16;if(T >= 292){T=192;}}break;
- case 4:{T += 1;if(T >= 176){T= 16;}}break;
- case 5:{T += 1;if(T >= 288){T=192;}}break;
- case 6:{T += 1;if(T>=176)T = 16;} break;
- case 7:{T += 1;if(T>=288)T = 192;} break;
- case 8:{T += 16;if(T>=192)T = 16;} break;
- case 9:{T += 16;if(T>=292)T = 192;} break;
- default: break;
- }
- /* if(GongNeng() == 1)
- {
- T += 16;
- if(T >= 176){T=16;}
- }
- if(GongNeng() == 2)
- {
- T += 16;
- if(T >= 192){T=176;}
- }
- if(GongNeng() == 3)
- {
- T += 16;
- if(T >=272){T=176;}
- }
- if(GongNeng() == 4)
- {
- T += 1;
- if(T >= 160){T=16;}
- }
- if(GongNeng() == 5)
- {
- T += 1;
- if(T >= 256){T=176;}
- }*/
- }
- refresh_led();
-
- }
复制代码
单片机16x16点阵源程序
51黑论坛_点阵显示汉字程序.rar
(43.06 KB, 下载次数: 36)
16x16点阵.rar
(7.11 MB, 下载次数: 88)
|