微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 用STC12C5A60S2直驱一个16*16LED点阵显示屏

用STC12C5A60S2直驱一个16*16LED点阵显示屏

时间:11-29 来源:互联网 点击:
看到51hei的坛子有坛友做的16X16LED汉字显示屏,作为生日礼物表情意,我也想着做一个!以满足动手爱好!

用AT89C52的,驱动电路复杂得不得了,32个三极管,32个电阻啊!焊得头到晕啊!还要个4-16译码电路!!!!!!
幸好有爱情的力量,为那个哥们辛苦为感动!

我呢,有STC12C5A60S2这个单片机的"神器",比AVR的还好.价不贵,才7元/片!有AD,PWM,端口四态,可最大驱动20MA电流!60KB的程序FLASH ROM.爽YY啊.一个简单电路就可以做成16X16的LED了. 8X8的双色是我2元/片淘来的!只用到了红色的!
电路简洁无比,就是一个单片机,四片8*8LED点阵,一个12M晶振,2个30P电容,(12M晶振,2个30P电容,可以省的.,便为了能在线下载,加上去方便下载程序)
电路这么简单,也是受到杜洋老师的影响,我这个还是列驱动,实测电流35MA,运行一个晚上,芯片安全.就不费心思研究杜老师的点驱动了!!!

程序也是学别人的,改了下就能用,C就是好啊!汇编的话,估计没那么方便!

//  本程序演示 STC12C5A60S2 系列直驱四个8*8LED点阵组成16X16点阵 //  //改编:桃源客, 日期:2010-9-19 //--------------------------------------------------------------------- //#include  #include  #include "STC12C5A60s2.H" //--------------------------------------------------------------------- typedef    unsigned char   uchar; typedef    unsigned int    uint; //以下字模为PC2LCD2000生成,选"阴码,逆向"方式. uchar code zimo1[1088]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0 x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0 x00,0x00,  //留一行空白16X16字符,作流动开始用. 0x20,0x04,0x20,0x04,0x22,0x42,0x22,0x82, 0xFE,0x7F,0x21,0x01,0x21,0x01,0x20,0x10, 0x20,0x10,0xFF,0x08,0x20,0x07,0x22,0x1A, 0xAC,0x21,0x20,0x40,0x20,0xF0,0x00,0x00,/*"我",0*/ /* (16 X 16 , 宋体 ) */ 0x00,0x40,0x40,0x20,0xB2,0xA0,0x96,0x90, 0x9A,0x4C,0x92,0x47,0xF6,0x2A,0x9A,0x2A, 0x93,0x12,0x91,0x1A,0x99,0x26,0x97,0x22, 0x91,0x40,0x90,0xC0,0x30,0x40,0x00,0x00,/*"爱",1*/ /* (16 X 16 , 宋体 ) */ 0x00,0x08,0x00,0x08,0xF8,0x0B,0x28,0x09, 0x29,0x09,0x2E,0x09,0x2A,0x09,0xF8,0xFF, 0x28,0x09,0x2C,0x09,0x2B,0x09,0x2A,0x09, 0xF8,0x0B,0x00,0x08,0x00,0x08,0x00,0x00,/*"单",2*/ /* (16 X 16 , 宋体 ) */ 0x00,0x80,0x00,0x40,0x00,0x30,0xFE,0x0F, 0x10,0x01,0x10,0x01,0x10,0x01,0x10,0x01, 0x10,0x01,0x1F,0x01,0x10,0x01,0x10,0xFF, 0x10,0x00,0x18,0x00,0x10,0x00,0x00,0x00,/*"片",3*/ /* (16 X 16 , 宋体 ) */ 0x08,0x04,0x08,0x03,0xC8,0x00,0xFF,0xFF, 0x48,0x00,0x88,0x41,0x08,0x30,0x00,0x0C, 0xFE,0x03,0x02,0x00,0x02,0x00,0x02,0x00, 0xFE,0x3F,0x00,0x40,0x00,0x78,0x00,0x00,/*"机",4*/ /* (16 X 16 , 宋体 ) */ 0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x38, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*",",5*/ /* (16 X 16 , 宋体 ) */ 0x20,0x04,0x20,0x04,0x22,0x42,0x22,0x82, 0xFE,0x7F,0x21,0x01,0x21,0x01,0x20,0x10, 0x20,0x10,0xFF,0x08,0x20,0x07,0x22,0x1A, 0xAC,0x21,0x20,0x40,0x20,0xF0,0x00,0x00,/*"我",6*/ /* (16 X 16 , 宋体 ) */ 0x00,0x40,0x40,0x20,0xB2,0xA0,0x96,0x90, 0x9A,0x4C,0x92,0x47,0xF6,0x2A,0x9A,0x2A, 0x93,0x12,0x91,0x1A,0x99,0x26,0x97,0x22, 0x91,0x40,0x90,0xC0,0x30,0x40,0x00,0x00,/*"爱",7*/ /* (16 X 16 , 宋体 ) */ 0x10,0x42,0x92,0x42,0x54,0x2A,0x38,0x2E, 0xFF,0x13,0x38,0x1A,0x54,0x26,0x52,0x02, 0x80,0x40,0xF0,0x20,0x1F,0x13,0x12,0x0C, 0x10,0x33,0xF0,0x60,0x10,0x20,0x00,0x00,/*"数",8*/ /* (16 X 16 , 宋体 ) */ 0x02,0x01,0x82,0x00,0xE2,0x7F,0x5E,0x10, 0x42,0x10,0xC2,0x3F,0x00,0x00,0x02,0x04, 0xFA,0x04,0x82,0x04,0x82,0x44,0x82,0x84, 0xFE,0x40,0x80,0x3F,0x00,0x00,0x00,0x00,/*"码",9*/ /* (16 X 16 , 宋体 ) */ 0x00,0x20,0x08,0x60,0x08,0x30,0x08,0x08, 0x08,0x18,0x08,0x24,0x09,0x24,0x0A,0x22, 0x0C,0x41,0x88,0x40,0x48,0x40,0x28,0x40, 0x1C,0x40,0x08,0x40,0x00,0x40,0x00,0x00,/*"之",10*/ /* (16 X 16 , 宋体 ) */ 0x00,0x00,0x18,0x29,0x04,0x29,0x14,0x15, 0x94,0x14,0x94,0x4A,0xD5,0x89,0xB6,0x44, 0x14,0x3F,0x14,0x06,0x94,0x09,0x04,0x09, 0x14,0x10,0x0C,0x30,0x04,0x10,0x00,0x00,/*"家",11*/ /* (16 X 16 , 宋体 ) */ 0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x38, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*",",12*/ /* (16 X 16 , 宋体 ) */ 0x20,0x04,0x20,0x04,0x22,0x42,0x22,0x82, 0xFE,0x7F,0x21,0x01,0x21,0x01,0x20,0x10, 0x20,0x10,0xFF,0x08,0x20,0x07,0x22,0x1A, 0xAC,0x21,0x20,0x40,0x20,0xF0,0x00,0x00,/*"我",13*/ /* (16 X 16 , 宋体 ) */ 0x80,0x00,0x40,0x00,0xF0,0x7F,0x1C,0x00, 0x03,0x00,0xF0,0x7F,0x01,0x00,0x0E,0x00, 0x04,0x00,0x00,0x00,0x04,0x00,0x04,0x20, 0x04,0x40,0xFC,0x3F,0x00,0x00,0x00,0x00,/*"们",14*/ /* (16 X 16 , 宋体 ) */ 0x00,0x04,0x04,0x02,0x04,0x01,0xC4,0x7F, 0x64,0x00,0x9C,0x20,0x87,0x20,0x84,0x20, 0x84,0x20,0xE4,0x3F,0x84,0x20,0x84,0x20, 0x84,0x20,0x84,0x20,0x04,0x20,0x00,0x00,/*"在",15*/ /* (16 X 16 , 宋体 ) */ 0x40,0x80,0x42,0x40,0x44,0x20,0xCC,0x1F, 0x00,0x20,0x08,0x40,0x28,0x50,0x48,0x48, 0x89,0x44,0x0E,0x43,0xCA,0x44,0x38,0x48, 0x08,0x50,0x08,0x40,0x00,0x40,0x00,0x00,/*"这",16*/ /* (16 X 16 , 宋体 ) */ 0x00,0x40,0x00,0x40,0xFF,0x44,0x91,0x44, 0x91,0x44,0x91,0x44,0x91,0x44,0xFF,0x7F, 0x91,0x44,0x91,0x44,0x91,0x44,0x91,0x44, 0xFF,0x44,0x00,0x40,0x00,0x40,0x00,0x00,/*"里",17*/ /* (16 X 16 , 宋体 ) */ 0x00,0x02,0x10,0x02,0x10,0x82,0x10,0x42, 0x10,0x32,0xFE,0x1F,0x10,0x0A,0x10,0x02, 0x10,0x02,0x10,0x06,0xFE,0x0B,0x10,0x32, 0x10,0xE2,0x10,0x42,0x00,0x02,0x00,0x00,/*"共",18*/ /* (16 X 16 , 宋体 ) */ 0x00,0x00,0xFE,0xFF,0x02,0x00,0x12,0x00, 0x92,0x1F,0x92,0x08,0x92,0x08,0x92,0x08, 0x92,0x08,0x92,0x08,0x92,0x1F,0x12,0x40, 0x02,0x80,0xFE,0x7F,0x00,0x00,0x00,0x00,/*"同",19*/ /* (16 X 16 , 宋体 ) */ 0x00,0x08,0x04,0x08,0x04,0x09,0x74,0x09, 0x54,0x09,0x54,0x29,0x55,0x49,0x56,0x89, 0x54,0x7D,0x54,0x0B,0x54,0x0B,0x74,0x09, 0x04,0x08,0x04,0x08,0x00,0x08,0x00,0x00,/*"享",20*/ /* (16 X 16 , 宋体 ) */ 0x80,0x00,0x62,0x80,0x26,0x80,0x2A,0x41, 0x32,0x43,0x22,0x25,0x26,0x29,0x3A,0x11, 0x2B,0x11,0x21,0x2D,0x31,0x23,0x2F,0x40, 0xA5,0xC0,0x60,0x40,0x20,0x00,0x00,0x00,/*"受",21*/ /* (16 X 16 , 宋体 ) */ 0x10,0x42,0x92,0x42,0x54,0x2A,0x38,0x2E, 0xFF,0x13,0x38,0x1A,0x54,0x26,0x52,0x02, 0x80,0x40,0xF0,0x20,0x1F,0x13,0x12,0x0C, 0x10,0x33,0xF0,0x60,0x10,0x20,0x00,0x00,/*"数",22*/ /* (16 X 16 , 宋体 ) */ 0x02,0x01,0x82,0x00,0xE2,0x7F,0x5E,0x10, 0x42,0x10,0xC2,0x3F,0x00,0x00,0x02,0x04, 0xFA,0x04,0x82,0x04,0x82,0x44,0x82,0x84, 0xFE,0x40,0x80,0x3F,0x00,0x00,0x00,0x00,/*"码",23*/ /* (16 X 16 , 宋体 ) */ 0x80,0x00,0x64,0x00,0x24,0x00,0x24,0x3F, 0x3F,0x01,0x24,0x01,0x24,0x01,0xFF,0xFF, 0x24,0x01,0x24,0x11,0x24,0x21,0x3F,0x1F, 0xA4,0x00,0x64,0x00,0x24,0x00,0x00,0x00,/*"带",24*/ /* (16 X 16 , 宋体 ) */ 0x20,0x22,0x30,0x23,0xAC,0x22,0x63,0x12, 0x10,0x12,0x40,0x00,0x20,0x00,0x50,0x7E, 0x4C,0x42,0x43,0x42,0x44,0x42,0x48,0x42, 0x30,0x7E,0x60,0x00,0x20,0x00,0x00,0x00,/*"给",25*/ /* (16 X 16 , 宋体 ) */ 0x20,0x04,0x20,0x04,0x22,0x42,0x22,0x82, 0xFE,0x7F,0x21,0x01,0x21,0x01,0x20,0x10, 0x20,0x10,0xFF,0x08,0x20,0x07,0x22,0x1A, 0xAC,0x21,0x20,0x40,0x20,0xF0,0x00,0x00,/*"我",26*/ /* (16 X 16 , 宋体 ) */ 0x80,0x00,0x40,0x00,0xF0,0x7F,0x1C,0x00, 0x03,0x00,0xF0,0x7F,0x01,0x00,0x0E,0x00, 0x04,0x00,0x00,0x00,0x04,0x00,0x04,0x20, 0x04,0x40,0xFC,0x3F,0x00,0x00,0x00,0x00,/*"们",27*/ /* (16 X 16 , 宋体 ) */ 0x00,0x00,0xF8,0x7F,0x8C,0x10,0x8B,0x10, 0x88,0x10,0xF8,0x3F,0x40,0x00,0x30,0x00, 0x8F,0x00,0x08,0x03,0x08,0x26,0x08,0x40, 0x08,0x20,0xF8,0x1F,0x00,0x00,0x00,0x00,/*"的",28*/ /* (16 X 16 , 宋体 ) */ 0x70,0x00,0x00,0x00,0xFF,0xFF,0x08,0x00, 0xB0,0x80,0x88,0x40,0x88,0x30,0x88,0x0E, 0xFF,0x01,0x88,0x06,0x88,0x08,0x88,0x30, 0xF8,0x60,0x80,0xC0,0x80,0x40,0x00,0x00,/*"快",29*/ /* (16 X 16 , 宋体 ) */ 0x00,0x00,0x00,0x20,0x40,0x18,0xFC,0x0C, 0x44,0x07,0x44,0x12,0x44,0x20,0x46,0x40, 0xFA,0x3F,0x42,0x00,0x43,0x00,0x43,0x02, 0x42,0x0C,0x40,0x38,0x00,0x10,0x00,0x00,/*"乐",30*/ /* (16 X 16 , 宋体 ) */ 0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x5F, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"!",31*/ /* (16 X 16 , 宋体 ) */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0 x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0 x00,0x00,  //最后留一空白字符. }; uchar code  tab[]= {0x7f,0xff,0xbf,0xff,0xdf,0xff,0xef,0xff,0xf7,0xff,0xfb,0xff,0xfd,0xff, 0xfe, 0xff,         0xff, 0x7f,0xff,0xbf,0xff,0xdf,0xff,0xef,0xff,0xf7,0xff,0xfb,0xff,0xfd,0xff,0 xfe }; //16列扫描分时输出,从右到左每次输出1列 ,低电平有效. bit SHAN;   //以下变量作为时钟计数用,本程序单显汉字,未用到. uchar second,minute,hour; void init();   //初始化函数. #define HAN1  P1            //定义p1口为行0-行7数据口 #define HAN2  P3            //定义p3口为行8-行15数据口 #define LIE1  P2           //定义p2口为列1-行7数据口 #define LIE2  P0            //定义p0口为列8-列15数据口 void delay(uchar delay_time);       //延时函数 //--------------------------------------------------------------------- void main() {uchar  i ,speed; uint  k ; init();         //初始化STC12C5A60S2的P0-P3端口为强推输出,每端 口输出可输出20MA电流,可直驱8X8LED点阵. while(1) { for( k = 0 ; k <1056 ;k += 2 )              //以下的循 环体为流动显示16X16字符. {  for( speed = 0 ; speed <10 ; speed++)     //改 变这行参数可以改速度. { for(i=0 ;i <16 ; i++) { LIE1=0xff; LIE2=0xff; HAN1 = zimo1[2*i + k ]  ; HAN2 = zimo1[2*i+1+ k]  ; LIE2=tab[2*i]; LIE1=tab[2*i+1]; delay(20) ; LIE1=0xff; LIE2=0xff; } }  } }; } //--------------------------------------------------------------------- void delay(uchar t)        // 延时函数 { uchar i;               //定义变量 for(;t>0;t--)             //如果t大于0,t减1(外层循环) for(i=124;i>0;i--);         //i等于124,如果i大于0,i减1 } //--------------------------------------------------------------------- /*************************************** 函 数 名:init 功    能:初始化函数 说    明:初始化定时器及中断 入口参数:无 返 回 值:无 ***************************************/ void init() { TMOD=1;TH0=0X3C;TL0=0XB0;       //定时器0模式1,50毫秒 ET0=1;TR0=1;EA=1;           //开定时器0中断、启动定时器0、开总中断 P4SW=0xff;                  //定义P4口为I/O口 P0M1=0x00; P0M0=0xff;                //定义P0为强上拉输出. P1M1=0x00; P1M0=0xff;                //定义P1为强上拉输出. P2M1=0x00; P2M0=0xff;                //定义P2为强上拉输出. P3M1=0x00; P3M0=0xff;                //定义P3为强上拉输出. P4M1=0x00; P4M0=0xff;                //定义P4为强上拉输出. } /********************************************************************** ****** 函数功能:定时器中断延时程序 这一段的作用计时用,程序中没有用到,保留作为 计时时钟或延时用. 入口参数: 出口参数: *********************************************************************** *****/ void timer0(void) interrupt 1 {  uchar tim1,tim2;           //定义临时变量 TL0=TL0+0XB0;TH0=0X3C;        //重装定时器初值 tim1++;                //每中断一次tim1加1 if(tim1==10)             //中断10(0.5秒) {                   SHAN=!SHAN;             //闪烁标志取反 tim1=0;tim2++;           //tim1清零,tim2加1 if(tim2==2)             //到了1秒 { tim2=0;second++;         //tim2清零,秒加1 if(second==60)          //如果秒到60 {                 second=0;minute++;       //秒变0,分加1 if(minute==60)         //如果分到60 { minute=0;hour++;       //分变0,时加1 if(hour==24) hour=0;     //如果时到24,时变0 } } } } } 

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top