发布网友 发布时间:2022-05-16 08:37
共2个回答
热心网友 时间:2023-10-17 00:09
首先你的点阵式几乘几的?单屏貌似显示不了,16*16可现实一个汉字,汉字有专门的代码生成软件生成16进制代码。我给你两个当时做的点阵的程序,是mega8做的,用的是595串转并。你可以看下然后自行修改,程序是可以用的。一个是8*8显示的,一个是16*16的 8*8显示程序: #include <iom16v.h> #include <macros.h> #define uchar unsigned char #define uint unsigned int const tabPB[8]=; //const tabPD[8]=; const tabPD[8]=; //心形 //const tabPD[8]=; //中字 void delay(uint n) //延时 { uint i; int j; for(i=0;i<n;i++) { for(j=0;j<1440;j++) } } void main() { DDRD=0XFF; PORTB=0XFF; PORTD=0X00; DDRB=0XFF; while(1) { int i; for(i=0;i<8;i++) //1ms显示一行,因为时间很短,所以图形看起来是静态的 { PORTB=0X00; PORTD=tabPD[i]; PORTB=tabPB[i]; delay(1); } } } /****************************************************************************** 名称 :点阵屏控制16*16 cpu : mega8 晶振 :内部8M ******************************************************************************/ #include <iom8v.h> #include <macros.h> #define uchar unsigned char #define uint unsigned int /******************************************************************************/ /********************************宏定义***************************************/ /******************************************************************************/ /* SER1--PD0 SER2--PD1 RCK1--PD2 RCK2--PD3 SCK1--PD5 SCK2--PD6 /*******************************************************************************/ #define H595DDR_OUT DDRD |=BIT(0)|BIT(5)|BIT(2) #define H595CTL PORTD //高低高平 #define H595_SER_H H595CTL |= BIT(PD0) //数据 #define H595_SER_L H595CTL &= ~BIT(PD0) #define H595_RCK_H H595CTL |= BIT(PD2) //副寄存器时钟 #define H595_RCK_L H595CTL &= ~BIT(PD2) #define H595_SCK_H H595CTL |= BIT(PD5) //主时钟 #define H595_SCK_L H595CTL &= ~BIT(PD5) #define H595DDR_OUT1 DDRD |=BIT(1)|BIT(3)|BIT(6) #define H595CTL1 PORTD //高低高平 #define H595_SER1_H H595CTL1 |= BIT(PD1) //数据 #define H595_SER1_L H595CTL1 &= ~BIT(PD1) #define H595_RCK1_H H595CTL1 |= BIT(PD3) //副寄存器时钟 #define H595_RCK1_L H595CTL1 &= ~BIT(PD3) #define H595_SCK1_H H595CTL1 |= BIT(PD6) //主时钟 #define H595_SCK1_L H595CTL1 &= ~BIT(PD6) #define ran_speed 30 uchar zimo[]= { // 电(0) 子(1) 科(2) 技(3) 班(4) 杨(5) 有(6) 才(7) 来(8) 了(9) ,(10) 大(11) 家(12) 热(13) 烈(14) 欢(15) // 迎(16) !(17) 0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xC0,0x07,0xDE,0xF7,0xDE,0xF7,0xC0,0x07,0xDE,0xF7, 0xDE,0xF7,0xDE,0xF7,0xC0,0x07,0xDE,0xF7,0xFE,0xFD,0xFE,0xFD,0xFF,0x01,0xFF,0xFF,/*"电",0*/ 0xFF,0xFF,0xC0,0x0F,0xFF,0xDF,0xFF,0xBF,0xFF,0x7F,0xFE,0xFF,0xFE,0xFF,0xFE,0xFB, 0x00,0x01,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFA,0xFF,0xFD,0xFF,/*"子",1*/ 0xF9,0xF7,0x87,0x77,0xF7,0xB7,0xF7,0xB7,0x01,0xF7,0xE7,0x77,0xE3,0xB7,0xD5,0xB7, 0xD7,0xF1,
热心网友 时间:2023-10-17 00:10
dsadsa