为了给集训队的学生训练,购买了一些电子套件 其中包括这个老李的摇摇棒。呵呵,由于老李的程序原来只提供HEX文件,后来拿到了汇编文件,但是汇编的程序要换个内容比较麻烦,所以就自己写了个C的程序。如下:
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
#include <reg51.h>//寄存器预定义
sbit kaiguan=P3^5;//水银开关,用于检测是否甩到左边
sbit genghuan=P3^0;//内容更换按钮,按下按钮更换显示内容
unsigned char linshi,jishu,index;//临时变量,扫描计数变量,内容变量
unsigned char *DISP;//显示指针,该指针指向不同的地址,则显示不同的内容
//以下点阵数据使用字模3软件制作,纵向取模,字节正序,反色
unsigned char code index1[]={中国欧软4457430
/*------------------------------------------------------------------------------
; 源文件 / 文字 : ★■
; 宽×高(像素): 36×12
------------------------------------------------------------------------------*/
0xFF,0xE3,0xC1,0xC1,0xC0,0xE0,0xE0,0xC0,0xC1,0xC1,0xE3,0xFF,0xF7,0xF3,0xF3,0xF0,
0xC0,0x00,0xC0,0xF0,0xF3,0xF3,0xF7,0xFF,0xFF,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0xFF,0xFF,0xF0,0xF0,0xF0,0xF0,0xF0,0x70,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,
0xF0,0xD0,0x30,0x70,0x70,0xF0,0x70,0x70,0x30,0xD0,0xF0,0xF0,0xF0,0x30,0x30,0x30,
0x30,0x30,0x30,0x30,0x30,0x30,0xF0,0xF0,
};中国欧软4457430
unsigned char code index2[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : I心U
; 宽×高(像素): 36×12
------------------------------------------------------------------------------*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xDF,0xDF,0xC0,0xDF,0xDF,0xFF,0xFF,0xE3,0xC1,0xC1,
0xC0,0xE0,0xE0,0xC0,0xC1,0xC1,0xE3,0xFF,0xDF,0xC0,0xFF,0xFF,0xC0,0xDF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xB0,0xB0,0x30,0xB0,0xB0,0xF0,
0xF0,0xF0,0xF0,0xF0,0xF0,0x70,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0x70,0xB0,0xB0,
0x70,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,
};中国欧软4457430
unsigned char code index3[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 笑脸
; 宽×高(像素): 36×12
------------------------------------------------------------------------------*/
0xFF,0xF0,0xEF,0xDC,0xB7,0xBF,0xBF,0xB7,0xDC,0xEF,0xF0,0xFF,0xFF,0xF0,0xEF,0xDC,
0xB7,0xBF,0xBF,0xB7,0xDC,0xEF,0xF0,0xFF,0xFF,0xF0,0xEF,0xDC,0xB7,0xBF,0xBF,0xB7,
0xDC,0xEF,0xF0,0xFF,0xF0,0xF0,0x70,0xB0,0x50,0x50,0x50,0x50,0xB0,0x70,0xF0,0xF0,
0xF0,0xF0,0x70,0xB0,0x50,0x50,0x50,0x50,0xB0,0x70,0xF0,0xF0,0xF0,0xF0,0x70,0xB0,
0x50,0x50,0x50,0x50,0xB0,0x70,0xF0,0xF0,
};中国欧软4457430
unsigned char code index4[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : (@﹏@)
; 宽×高(像素): 36×12
------------------------------------------------------------------------------*/
0xFF,0xFF,0xFF,0xE0,0xDF,0xBF,0xE0,0xDF,0xD8,0xD6,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0xDF,0xD8,0xD6,0xE0,0xFF,0xFF,0xBF,
0xDF,0xE0,0xFF,0xFF,0xF0,0xF0,0xF0,0x70,0xB0,0xD0,0x70,0xB0,0xB0,0xB0,0xB0,0xF0,
0xD0,0xB0,0xB0,0xB0,0xD0,0xD0,0xB0,0xB0,0xD0,0xD0,0xB0,0xF0,0x70,0xB0,0xB0,0xB0,
0xB0,0xF0,0xF0,0xD0,0xB0,0x70,0xF0,0xF0,
};
unsigned char code index5[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 答对了
; 宽×高(像素): 36×12中国欧软4457430
------------------------------------------------------------------------------*/
0xED,0xDD,0x3A,0x92,0xAA,0xAA,0x92,0x3A,0x9A,0xAD,0xBD,0xFF,0xBF,0xAF,0xB6,0xB9,
0x86,0xEF,0xEB,0xEC,0xEF,0x00,0xEF,0xFF,0xFF,0x7F,0x7F,0x7F,0x7F,0x60,0x6F,0x5F,
0x3F,0x7F,0xFF,0xFF,0xF0,0xF0,0x10,0xD0,0xD0,0xD0,0xD0,0xD0,0x10,0xF0,0xF0,0xF0,
0xB0,0x70,0xF0,0xF0,0x30,0xF0,0xF0,0xD0,0xD0,0x10,0xF0,0xF0,0xF0,0xF0,0xF0,0xD0,
0xD0,0x10,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,
};
unsigned char code index6[]={中国欧软4457430
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 你是猪
; 宽×高(像素): 36×12
------------------------------------------------------------------------------*/
0xF7,0xEF,0xC0,0x37,0xEE,0x99,0x5F,0xD0,0xDF,0xD9,0xCE,0xFF,0xFD,0xFD,0xFC,0x05,
0x55,0x54,0x55,0x55,0x05,0xFD,0xFD,0xFF,0x76,0xAD,0xC0,0x37,0xD6,0xD4,0x01,0xD5,
0xC5,0x94,0xF7,0xFF,0xF0,0xF0,0x10,0x70,0xF0,0xD0,0xD0,0x10,0xF0,0xF0,0x70,0xF0,
0xD0,0xB0,0x70,0x70,0xB0,0x10,0x50,0x50,0x50,0x50,0xD0,0xF0,0xD0,0xD0,0x30,0x70,
0xF0,0x10,0x50,0x50,0x50,0x10,0xF0,0xF0,
};
unsigned char code index7[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 我爱你
; 宽×高(像素): 36×12
------------------------------------------------------------------------------*/
0xAE,0xAE,0xAD,0x80,0x6D,0xEB,0x01,0xEE,0x6D,0xAB,0xEF,0xFF,0xE7,0xAB,0xAB,0x8B,
0xA0,0x8A,0x6A,0x4A,0x2A,0x6B,0xE7,0xFF,0xF7,0xEF,0xC0,0x37,0xEE,0x99,0x5F,0xD0,
0xDF,0xD9,0xCE,0xFF,0xF0,0xD0,0xD0,0x10,0xB0,0xB0,0x70,0x70,0xB0,0xD0,0x10,0xF0,
0xD0,0xD0,0xB0,0x50,0x50,0xB0,0xB0,0x50,0xD0,0xD0,0xD0,0xF0,0xF0,0xF0,0x10,0x70,
0xF0,0xD0,0xD0,0x10,0xF0,0xF0,0x70,0xF0,
};中国欧软4457430
unsigned char code index8[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 好喜欢
; 宽×高(像素): 36×12
------------------------------------------------------------------------------*/
0xDC,0xC2,0x1F,0xDC,0xC3,0x7B,0x7B,0x60,0x5B,0x3B,0xFB,0xFF,0xBE,0xBE,0xA2,0xAA,
0xA8,0x0A,0xAA,0xA8,0xA2,0xBE,0xBE,0xFF,0xAF,0xB6,0xB9,0x86,0xBF,0xE7,0x1E,0xD1,
0xDE,0xD7,0xCF,0xFF,0xD0,0xB0,0x70,0x70,0xB0,0xF0,0xD0,0x10,0xF0,0xF0,0xF0,0xF0,
0xF0,0xF0,0x10,0xD0,0xD0,0xD0,0xD0,0xD0,0x10,0xF0,0xF0,0xF0,0xB0,0x70,0xF0,0xD0,
0x50,0xB0,0x70,0xF0,0x70,0xB0,0xD0,0xF0,
};中国欧软4457430
unsigned char code index9[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : √√√
; 宽×高(像素): 36×12
------------------------------------------------------------------------------*/
0xFF,0xFF,0xFE,0xFD,0xFE,0xFF,0xFE,0xF1,0x8F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFD,
0xFE,0xFF,0xFE,0xF1,0x8F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFD,0xFE,0xFF,0xFE,0xF1,
0x8F,0xFF,0xFF,0xFF,0xF0,0xF0,0xF0,0xF0,0xF0,0x70,0x30,0xF0,0xF0,0xF0,0xF0,0xF0,
0xF0,0xF0,0xF0,0xF0,0xF0,0x70,0x30,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,
0xF0,0x70,0x30,0xF0,0xF0,0xF0,0xF0,0xF0,
};中国欧软4457430
unsigned char code index10[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : ×××
; 宽×高(像素): 36×12中国欧软4457430
------------------------------------------------------------------------------*/
0xFF,0xFF,0xDF,0xEE,0xF5,0xFB,0xF5,0xEE,0xDF,0xFF,0xFF,0xFF,0xFF,0xFF,0xDF,0xEE,
0xF5,0xFB,0xF5,0xEE,0xDF,0xFF,0xFF,0xFF,0xFF,0xFF,0xDF,0xEE,0xF5,0xFB,0xF5,0xEE,
0xDF,0xFF,0xFF,0xFF,0xF0,0xF0,0x70,0xF0,0xF0,0xF0,0xF0,0xF0,0x70,0xF0,0xF0,0xF0,
0xF0,0xF0,0x70,0xF0,0xF0,0xF0,0xF0,0xF0,0x70,0xF0,0xF0,0xF0,0xF0,0xF0,0x70,0xF0,
0xF0,0xF0,0xF0,0xF0,0x70,0xF0,0xF0,0xF0,
};
unsigned char code index11[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 笑脸中国欧软4457430
; 宽×高(像素): 36×12
------------------------------------------------------------------------------*/
0xFF,0xF0,0xE0,0xC3,0x88,0x80,0x80,0x88,0xC3,0xE0,0xF0,0xFF,0xFF,0xF0,0xE0,0xC3,
0x88,0x80,0x80,0x88,0xC3,0xE0,0xF0,0xFF,0xFF,0xF0,0xE0,0xC3,0x88,0x80,0x80,0x88,
0xC3,0xE0,0xF0,0xFF,0xF0,0xF0,0x70,0x30,0x90,0x90,0x90,0x90,0x30,0x70,0xF0,0xF0,
0xF0,0xF0,0x70,0x30,0x90,0x90,0x90,0x90,0x30,0x70,0xF0,0xF0,0xF0,0xF0,0x70,0x30,
0x90,0x90,0x90,0x90,0x30,0x70,0xF0,0xF0,
};
unsigned char code index12[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : %>_<%中国欧软4457430
; 宽×高(像素): 36×12
------------------------------------------------------------------------------*/
0xFF,0xFF,0xFF,0xE7,0xDB,0xE4,0xF2,0xCD,0xFE,0xFF,0xBF,0xDF,0xEE,0xF5,0xFB,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFB,0xF5,0xEE,0xDF,0xBF,0xE7,0xDB,0xE4,0xF2,0xCD,
0xFE,0xFF,0xFF,0xFF,0xF0,0xF0,0xF0,0xF0,0x30,0xF0,0x70,0xB0,0x70,0xF0,0xB0,0x70,
0xF0,0xF0,0xF0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xF0,0xF0,0xF0,0xF0,0x70,0xB0,0xF0,
0x30,0xF0,0x70,0xB0,0x70,0xF0,0xF0,0xF0,
};
unsigned char code index13[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : I?U
; 宽×高(像素): 36×12中国欧软4457430
------------------------------------------------------------------------------*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xDF,0xDF,0xC0,0xDF,0xDF,0xFF,0xFF,0xC7,0xB9,0x7E,
0x7F,0xBF,0xDF,0xBF,0x7F,0x7E,0xB9,0xC7,0xFF,0x80,0x80,0xFF,0xFF,0xFF,0x80,0x80,
0xFF,0xFF,0xFF,0xFF,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xB0,0xB0,0x30,0xB0,0xB0,0xF0,
0xF0,0xF0,0xF0,0xF0,0x70,0xB0,0xD0,0xB0,0x70,0xF0,0xF0,0xF0,0xF0,0x70,0x30,0xB0,
0xB0,0xB0,0x30,0x70,0xF0,0xF0,0xF0,0xF0,
};
unsigned char code index14[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 音乐
; 宽×高(像素): 36×12
------------------------------------------------------------------------------*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0xCF,0xE7,0xF0,0xFF,0xFF,0xFF,0xFE,0x80,
0x9F,0x9F,0xCF,0xC0,0xFF,0xFF,0xFF,0xFF,0xC0,0xDB,0xB7,0xB7,0x6F,0x6E,0x00,0xFF,
0xFF,0xFF,0xFF,0xFF,0xF0,0xF0,0xF0,0xF0,0xF0,0x90,0x10,0x30,0xF0,0x70,0xF0,0xF0,
0xF0,0x30,0x30,0x70,0xF0,0x90,0x10,0x30,0xF0,0xF0,0x90,0x10,0x30,0xF0,0xF0,0xF0,
0x30,0x30,0x70,0xF0,0xF0,0xF0,0xF0,0xF0,
};中国欧软4457430
unsigned char code index15[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 我≠你
; 宽×高(像素): 36×12
------------------------------------------------------------------------------*/
0xAE,0xAE,0xAD,0x80,0x6D,0xEB,0x01,0xEE,0x6D,0xAB,0xEF,0xFF,0xFF,0xF5,0xF5,0xF5,
0xF4,0xF1,0xE5,0x95,0xF5,0xF5,0xFF,0xFF,0xF7,0xEF,0xC0,0x37,0xEE,0x99,0x5F,0xD0,
0xDF,0xD9,0xCE,0xFF,0xF0,0xD0,0xD0,0x10,0xB0,0xB0,0x70,0x70,0xB0,0xD0,0x10,0xF0,
0xF0,0xF0,0xF0,0x30,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0x10,0x70,
0xF0,0xD0,0xD0,0x10,0xF0,0xF0,0x70,0xF0,
};
unsigned char code index16[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : ㏒10=?
; 宽×高(像素): 36×12中国欧软4457430
------------------------------------------------------------------------------*/
0x00,0xFF,0xF1,0xEE,0xEE,0xF1,0xFF,0xF0,0xEA,0xEA,0xD7,0xFF,0xFF,0xEF,0xC0,0xFF,
0xFF,0xFF,0xE0,0xDF,0xDF,0xDF,0xE0,0xFF,0xF6,0xF6,0xF6,0xF6,0xF6,0xFF,0xE7,0xDF,
0xDC,0xDB,0xE7,0xFF,0x30,0xB0,0xF0,0xF0,0xF0,0xF0,0x30,0xD0,0xD0,0xD0,0x30,0xF0,
0xF0,0xB0,0x30,0xB0,0xF0,0xF0,0x70,0xB0,0xB0,0xB0,0x70,0xF0,0xF0,0xF0,0xF0,0xF0,
0xF0,0xF0,0xF0,0xF0,0xB0,0xF0,0xF0,0xF0,
};
unsigned char code index17[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 你≌猪
; 宽×高(像素): 36×12中国欧软4457430
------------------------------------------------------------------------------*/
0xF7,0xEF,0xC0,0x37,0xEE,0x99,0x5F,0xD0,0xDF,0xD9,0xCE,0xFF,0xFF,0xE6,0xDA,0xDA,
0xFA,0xF6,0xEE,0xDE,0xDA,0xDA,0xE6,0xFF,0x76,0xAD,0xC0,0x37,0xD6,0xD4,0x01,0xD5,
0xC5,0x94,0xF7,0xFF,0xF0,0xF0,0x10,0x70,0xF0,0xD0,0xD0,0x10,0xF0,0xF0,0x70,0xF0,
0xF0,0xB0,0xB0,0xB0,0xB0,0xB0,0xB0,0xB0,0xB0,0xB0,0xB0,0xF0,0xD0,0xD0,0x30,0x70,
0xF0,0x10,0x50,0x50,0x50,0x10,0xF0,0xF0,
};
unsigned char code index18[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : √√√
; 宽×高(像素): 36×12
------------------------------------------------------------------------------*/
0xFF,0xFF,0xFE,0xFD,0xFE,0xFF,0xFE,0xF1,0x8F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFD,
0xFE,0xFF,0xFE,0xF1,0x8F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFD,0xFE,0xFF,0xFE,0xF1,
0x8F,0xFF,0xFF,0xFF,0xF0,0xF0,0xF0,0xF0,0xF0,0x70,0x30,0xF0,0xF0,0xF0,0xF0,0xF0,
0xF0,0xF0,0xF0,0xF0,0xF0,0x70,0x30,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,
0xF0,0x70,0x30,0xF0,0xF0,0xF0,0xF0,0xF0,
};
unsigned char code index19[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 99.5℃
; 宽×高(像素): 36×12中国欧软4457430
------------------------------------------------------------------------------*/
0xE3,0xDD,0xDD,0xDD,0xE0,0xFF,0xE3,0xDD,0xDD,0xDD,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xC3,0xDB,0xDB,0xDB,0xDC,0xFF,0x8F,0xAF,0x8F,0xE0,0xDF,0xBF,0xBF,0xBF,
0xDF,0x8E,0xFF,0xFF,0xF0,0x30,0xB0,0xB0,0x70,0xF0,0xF0,0x30,0xB0,0xB0,0x70,0xF0,
0xF0,0xB0,0xF0,0xF0,0xF0,0xF0,0x70,0xB0,0xB0,0xB0,0x70,0xF0,0xF0,0xF0,0xF0,0xF0,
0x70,0xB0,0xB0,0xB0,0xB0,0x70,0xF0,0xF0,
};
unsigned char code index20[]={
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 囧rz=3
; 宽×高(像素): 36×12
------------------------------------------------------------------------------*/
0xFF,0x00,0x77,0x6C,0x5D,0x7D,0x7D,0x5C,0x6F,0x77,0x00,0xFF,0xFB,0xF8,0xFD,0xFB,
0xFB,0xFF,0xFF,0xFB,0xFA,0xF9,0xFB,0xFF,0xF6,0xF6,0xF6,0xF6,0xF6,0xFF,0xEF,0xDF,
0xDB,0xDB,0xE4,0xFF,0xF0,0x10,0xD0,0x10,0xD0,0xD0,0xD0,0x10,0xD0,0xD0,0x10,0xF0,
0xB0,0x30,0xB0,0xF0,0xF0,0xF0,0xF0,0xB0,0x30,0xB0,0xB0,0xF0,0xF0,0xF0,0xF0,0xF0,
0xF0,0xF0,0x70,0xB0,0xB0,0xB0,0x70,0xF0,中国欧软4457430
};
void delay(unsigned char dtime)//延时函数,传递参数为无符号字符型,传递的
{ //参数越大,则延时时间约长,但不能大于255.
unsigned char temp; //函数内部使用的临时变量
while(dtime--) //外层循环
while(--temp); //内层循环
}
void main()
{
DISP=index1;//开机后将内容指针指向第一幅画面
index=0;//内容变量初始化中国欧软4457430
while(1)
{
if(!kaiguan)//是否甩到左边
{
delay(50);//由于换向时存在延时,因此延时一段时间,本延时影响显示内容的左右位置,越大越靠右
for(jishu=0;jishu<36;jishu++)//扫描循环,共36列数据
{
linshi=DISP[jishu];//获得高半截点阵数据
linshi=linshi>>3;//移动位置,使之对应LED
linshi=linshi|0xe1;//只保留D4-D1位数据
P3=linshi;//拼合数据,点亮LED中国欧软4457430
linshi=DISP[jishu];//获得高半截点阵数据
linshi=linshi<<4;//移动位置,使之对应LED
P1=0Xff;//熄灭P1口所有LED
linshi=linshi|0x0f;//保留高四位
P1=P1&linshi;//将高4位输出到P1
linshi=DISP[jishu+36];//获得下半截点阵数据
linshi=linshi>>4;//移位以对其LED
linshi=linshi|0xf0;//保留低四位中国欧软4457430
P1=P1&linshi;//低四位输出到P1
delay(1);//扫描延时,本延时影响字体宽度,延时时间越长,则字体越宽
}
P1=0XFF;//扫描完成,关闭LED
P3=P3|0X1E;//扫描完成,关闭LED
}
if(!genghuan)//更换内容按钮是否按下?
{
while(!genghuan);//等待按钮松开中国欧软4457430
index=index+1;//指向下一内容
if(index>19){index=0;}//判断内容是否超界
DISP=index*72+index1;//计算指针地址,由于每幅画面为36列,垂直像素为12,因此每幅画面占用72字节空间
P1=index^0xff;//将内容号显示在P1上的LED,便于观察
delay(100);//延时一段时间
P1=0XFF;//关闭P1LED显示
delay(100);//延时一段时间中国欧软4457430
P1=index^0xff;//将内容号显示在P1上的LED,便于观察
delay(100);//延时一段时间
P1=0XFF;//实现内容号的闪烁显示中国欧软4457430
}
}
} |