旋转led灯源代码
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar Disp_Line;
/***********************************************************************/
//时间定义
/***********************************************************************/
uchar Time_H; //时钟"时"(0~23)
uchar Time_M; //时钟"分"(0~59)
uchar Time_S; //时钟"秒"(0~59)
uchar Time_ms; //时钟"毫秒"(0~49) (每过20ms,+1)
uchar Timer1_JSQ;
/***********************************************************************/
//指针定位
/***********************************************************************/
uchar H_Line; //时针定位(0~179)
uchar M_Line; //分针定位(0~179)
uchar S_Line; //秒针定位(0~179)
uchar Disp_time_set; //定时器赋初值
uchar Disp_buffer[10];
/***********************************************************************/
//标志位定义
/***********************************************************************/
bit T20ms_flag; //20毫秒定时溢出标志(0=未溢出,1=溢出)
bit New_disp_flag; //显示刷新使能标志(0=禁止,1=使能)
uchar SET_EN_FLAG;
uchar Disp_mode;
uchar speednow,speed;
uchar k,l,m;
uint Mode_J;
/***********************************************************************/
//显示段码表(模拟表盘)(7*7)
/***********************************************************************/
uchar code LED_TAB_12369[]=
{
0x8C,0x92,0xA2,0xC2,0x84,0x00,0xFE, //12 正向 //0
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x82,0x82,0xFC,0x80,0x82,0x7C, //9 左旋270 度 //3
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x92,0x92,0x92,0x92,0x92,0x4C, //6 左旋180 度 //2
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x82,0x2, 0x1C,0x2, 0x82,0x7C, //3 左旋90 度 //1
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};
/***********************************************************************/
//数字字模显示段码表(8*8)
/***********************************************************************/
uchar code LED_TAB_A0[]=
{
//字符编号
0x7C,0x82,0x82,0x82,0x82,0x82,0x7C,0x00, //0 //0
0x00,0x80,0x80,0xFE,0x84,0x80,0x00,0x00, //1 //1
0x8C,0x92,0x92,0xA2,0xA2,0xC2,0xC4,0x00, //2 //2
0x6C,0x92,0x92,0x92,0x82,0x82,0x44,0x00, //3 //3
0x40,0x40,0xFE,0x44,0x48,0x50,0x60,0x00, //4 //4
0x60,0x92,0x92,0x92,0x92,0x92,0x4E,0x00, //5 //5
0x64,0x92,0x92,0x92,0x92,0x92,0x7C,0x00, //6 //6
0x02,0x06,0x0A,0xF2,0x02,0x02,0x02,0x00, //7 //7
0x6C,0x92,0x92,0x92,0x92,0x92,0x6C,0x00, //8 //8
0x7C,0x92,0x92,0x92,0x92,0x92,0x4C,0x00, //9 //9
0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x00, //://10
0x04,0x0A,0x04,0x78,0x84,0x84,0x48,0x00, //℃//11
};
/***********************************************************************/ //符号字模显示段码表(8*16)
/***********************************************************************/ uchar code num1[] =
{
/*-- 文字: 0 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*///上部
0xFF,0x1F,0xEF,0xF7,0xF7,0xEF,0x1F,0xFF,
/*-- 文字: 1 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xFF,0xFF,0xFF,0x07,0xEF,0xEF,0xFF,
/*-- 文字: 2 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0x8F,0x77,0xF7,0xF7,0xF7,0x8F,0xFF,
/*-- 文字: 3 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xCF,0xB7,0x77,0x77,0xF7,0xCF,0xFF,
/*-- 文字: 4 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xFF,0x07,0xEF,0xDF,0x3F,0xFF,0xFF,
/*-- 文字: 5 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xF7,0xF7,0x77,0x77,0xF7,0x07,0xFF,
/*-- 文字: 6 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xFF,0xE7,0x77,0x77,0xEF,0x1F,0xFF,
/*-- 文字: 7 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xF7,0xC7,0x37,0xF7,0xF7,0xC7,0xFF,
/*-- 文字: 8 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0x8F,0x77,0xF7,0xF7,0x77,0x8F,0xFF,
/*-- 文字: 9 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0x1F,0xEF,0xF7,0xF7,0xEF,0x1F,0xFF,
/*-- 文字: : --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xFF,0xFF,0x3F,0x3F,0xFF,0xFF,0xFF,
};
uchar code num2[]=
{
/*-- 文字: 0 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*///下部
0xFF,0xF0,0xEF,0xDF,0xDF,0xEF,0xF0,0xFF,
/*-- 文字: 1 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xFF,0xDF,0xDF,0xC0,0xDF,0xDF,0xFF,
/*-- 文字: 2 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xCF,0xDE,0xDD,0xDB,0xD7,0xCF,0xFF,
/*-- 文字: 3 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xF1,0xEE,0xDF,0xDF,0xDF,0xE7,0xFF,
/*-- 文字: 4 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xDB,0xC0,0xDB,0xDB,0xFB,0xF8,0xFF,
/*-- 文字: 5 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xF1,0xEE,0xDF,0xDF,0xDE,0xE6,0xFF,
/*-- 文字: 6 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xF1,0xEE,0xDF,0xDF,0xEE,0xF0,0xFF,
/*-- 文字: 7 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xFF,0xFF,0xFF,0xC0,0xFF,0xFF,0xFF,
/*-- 文字: 8 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xE3,0xDD,0xDE,0xDE,0xDD,0xE3,0xFF,
/*-- 文字: 9 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xF0,0xEE,0xDD,0xDD,0xCE,0xFF,0xFF,
/*-- 文字: : --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xFF,0xFF,0xCF,0xCF,0xFF,0xFF,0xFF,
};
uchar code num3[]=
{
/*-- 文字: 0 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xF8,0xF7,0xEF,0xEF,0xF7,0xF8,0xFF,0xFF,0x0F,0xF7,0xFB,0xFB,0xF7,0x0F,0xFF ,
/*-- 文字: 1 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xF7,0xF7,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFB,0xFB,0x03,0xFB,0xFB,0xFF,0xFF ,
/*-- 文字: 2 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xF1,0xEF,0xEF,0xEF,0xEE,0xF1,0xFF,0xFF,0xF3,0xEB,0xDB,0xBB,0x7B,0xF3,0xFF ,
/*-- 文字: 3 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xF3,0xEF,0xEE,0xEE,0xED,0xF3,0xFF,0xFF,0xE7,0xFB,0xFB,0xFB,0x77,0x8F,0xFF ,
/*-- 文字: 4 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xFF,0xFC,0xFB,0xF7,0xE0,0xFF,0xFF,0xFF,0x1F,0xDF,0xDB,0xDB,0x03,0xDB,0xFF ,
/*-- 文字: 5 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xE0,0xEF,0xEE,0xEE,0xEF,0xEF,0xFF,0xFF,0x67,0x7B,0xFB,0xFB,0x77,0x8F,0xFF
/*-- 文字: 6 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xF8,0xF7,0xEE,0xEE,0xE7,0xFF,0xFF,0xFF,0x0F,0x77,0xFB,0xFB,0x77,0x8F,0xFF ,
/*-- 文字: 7 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xE3,0xEF,0xEF,0xEC,0xE3,0xEF,0xFF,0xFF,0xFF,0xFF,0x03,0xFF,0xFF,0xFF,0xFF ,
/*-- 文字: 8 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xF1,0xEE,0xEF,0xEF,0xEE,0xF1,0xFF,0xFF,0xC7,0xBB,0x7B,0x7B,0xBB,0xC7,0xFF ,
/*-- 文字: 9 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xF8,0xF7,0xEF,0xEF,0xF7,0xF8,0xFF,0xFF,0xFF,0x73,0xBB,0xBB,0x77,0x0F,0xFF ,
/*-- 文字: r --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFE,0xFE,0xFE,0xFF,0xFE,0xFE,0xFE,0xFF,0xFB,0xFB,0x03,0x7B,0xFB,0xFF,0x7F,0xFF ,
/*-- 文字: / --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xFF,0xFF,0xFF,0xFE,0xF9,0xE7,0xDF,0xFF,0xF9,0xE7,0x9F,0x7F,0xFF,0xFF,0xFF ,
/*-- 文字: s --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xFF,0xFF,0xFE,0xFE,0xFE,0xFE,0xFE,0xFF,0xFF,0x33,0xDB,0xDB,0xDB,0xDB,0x67,0xFF ,
};
uchar code hanzi1[]=
//上部
{
0xFE,0x76,0x96,0xF6,0xE0,0xD6,0x36,0xF6,0xF6,0xFF,0x80,0xBF,0xB9,0xA6,0x9F,0xFF ,
/*-- 文字: 郑 --*/
0xFF,0xF8,0xFF,0xFF,0x00,0xFB,0xFC,0xFF,0x80,0xF7,0xF9,0xFE,0xFF,0x00,0xFF,0xFF ,
/*-- 文字: 州 --*/
0xFB,0xFB,0xFB,0xFB,0xFB,0xFB,0xFA,0x01,0xFA,0xFB,0xFB,0xFB,0xFB,0xFB,0xFB,0xFF ,
/*-- 文字: 大 --*/
0xFD,0xF3,0xF7,0xB7,0xC5,0xD5,0xF5,0x75,0x85,0xD4,0xF5,0xE7,0x15,0xB3,0xF7,0xFF ,
/*-- 文字: 学 --*/
0xBF,0xB0,0xB7,0xB7,0xB7,0x80,0xB7,0xB7,0xB7,0x80,0xB7,0xB7,0xB7,0xB0,0xBF,0xFF ,
/*-- 文字: 西 --*/
0xFF,0xBF,0xBB,0xBC,0xBF,0xBF,0x80,0xBF,0xBF,0x80,0xBF,0xBF,0xB0,0xBB,0xBF,0xFF ,
/*-- 文字: 亚 --*/
0xDF,0xDF,0x00,0xD6,0xD6,0xD6,0x00,0xDF,0xFF,0x80,0xBB,0xBB,0x78,0x7B,0xFB,0xFF ,
/*-- 文字: 斯 --*/
0xFF,0x80,0xBF,0xAF,0xAE,0xAE,0xAE,0xA0,0xAE,0xAE,0xAE,0xAF,0xBF,0x80,0xFF,0xFF ,
/*-- 文字: 国 --*/
0x80,0xBF,0xBB,0xA5,0x9E,0xFB,0xFB,0xBB,0xBB,0xB8,0xBB,0xBB,0xBB,0xBB,0xFB,0xFF
/*-- 文字: 际 --*/
0xFD,0xF3,0xF7,0xB7,0xC5,0xD5,0xF5,0x75,0x85,0xD4,0xF5,0xE7,0x15,0xB3,0xF7,0xFF ,
/*-- 文字: 学 --*/
0x80,0xBF,0xB3,0xAD,0x9E,0xCF,0xDB,0xDB,0x5B,0x9B,0xDB,0xDB,0xDB,0xCF,0xDF,0xFF ,
/*-- 文字: 院 --*/
};
uchar code hanzi2[]= //下部
{
/*-- 文字: 郑 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFB,0xFB,0xF7,0xCF,0x3F,0xBF,0xDF,0xE7,0xFF,0xFF,0x00,0xEF,0xEF,0xF7,0x0F,0xFF ,
/*-- 文字: 州 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x7F,0xFE,0xF9,0xE7,0x1F,0xFF,0xFF,0xFF,0x01,0xFF,0xFF,0x7F,0xFF,0x00,0xFF,0xFF ,
/*-- 文字: 大 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFF,0xFE,0xFD,0xFB,0xF7,0xCF,0x3F,0xFF,0x7F,0x9F,0xEF,0xF3,0xF9,0xFC,0xFD,0xFF ,
/*-- 文字: 学 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFF,0xBF,0xBF,0xBF,0xBF,0xBF,0xBD,0xBE,0x01,0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xFF ,
/*-- 文字: 西 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFF,0x01,0xEB,0xDB,0xBB,0x7B,0xFB,0xFB,0xFB,0x7B,0xBB,0xBB,0xBB,0x01,0xFF,0xFF ,
/*-- 文字: 亚 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFB,0xFB,0xFB,0xFB,0x1B,0xFB,0x03,0xFB,0xFB,0x03,0xDB,0x3B,0xFB,0xF3,0xFB,0xFF ,
/*-- 文字: 斯 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xDD,0xDB,0x13,0xDF,0xDF,0xD7,0x19,0xDD,0xF3,0x0F,0xFF,0xFF,0x00,0xFF,0xFF,0xFF ,
/*-- 文字: 国 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFF,0x00,0xFD,0xED,0xED,0xED,0xED,0x0D,0xED,0x6D,0x8D,0xED,0xFD,0x00,0xFF,0xFF ,
/*-- 文字: 际 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xFF,0xBF,0xDF,0x37,0xCF,0x3F,0xFD,0xFE,0x01,0xFF,0x7F,0xBF,0xC7,0xEF,0xFF ,
/*-- 文字: 学 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFF,0xBF,0xBF,0xBF,0xBF,0xBF,0xBD,0xBE,0x01,0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xFF ,
/*-- 文字: 院 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xFF,0xBF,0xDF,0x3E,0x7D,0x73,0x0F,0x7F,0x7F,0x01,0x7E,0x7E,0x7E,0x70,0xFF, };
uchar code dis_code1[19][16]=
{
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x04,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x12,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x12,0x22,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x12,0x22,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x12,0x22,0x44,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x12,0x22,0x44,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x12,0x22,0x44,0x20,0x10,0x08,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x12,0x22,0x44,0x20,0x10,0x0C,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x12,0x22,0x44,0x20,0x12,0x0C,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x12,0x22,0x44,0x22,0x12,0x0C,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x1E,0x22,0x44,0x22,0x12,0x0C,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x1E,0x3E,0x44,0x22,0x12,0x0C,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x1E,0x3E,0x7C,0x22,0x12,0x0C,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x1E,0x3E,0x7C,0x3E,0x12,0x0C,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x1E,0x3E,0x7C,0x3E,0x1E,0x0C,0x00,0x00,0x00,0x00,0x0 0},
};
uchar code dis_code2[20][16]=
{
{0x88,0x10,0x88,0x48,0x30,0x00,0x00,0x00,0x00,0x00,0x06,0x09,0x11,0x22,0x11,0x0 9},
{0x24,0x44,0x88,0x44,0x24,0x18,0x00,0x00,0x00,0x0C,0x12,0x22,0x44,0x22,0x12,0x0 C},
{0x0C,0x12,0x22,0x44,0x22,0x12,0x0C,0x00,0x0C,0x12,0x22,0x44,0x22,0x12,0x0C,0x0 0},
{0x00,0x0C,0x12,0x22,0x44,0x22,0x12,0x0C,0x12,0x22,0x44,0x22,0x12,0x0C,0x00,0x0 0},
{0x00,0x00,0x0C,0x12,0x22,0x44,0x2E,0x12,0x2E,0x44,0x22,0x12,0x0C,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x0C,0x12,0x2E,0x56,0x22,0x56,0x2E,0x12,0x0C,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x12,0x22,0x44,0x22,0x12,0x0C,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x1E,0x3E,0x7C,0x3E,0x1E,0x0C,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x0C,0x12,0x22,0x44,0x22,0x12,0x0C,0x00,0x00,0x00,0x00,0x0
0},
{0x00,0x00,0x00,0x00,0x0C,0x1E,0x3E,0x7C,0x3E,0x1E,0x0C,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x00,0x06,0x0F,0x1F,0x3E,0x1F,0x0F,0x06,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x0F,0x1F,0x0F,0x07,0x03,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0F,0x07,0x03,0x01,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x03,0x01,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x01,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0},
};
void init()
{
EA=1;
IT0=1;
EX0=1;
TMOD=0x11; //timer0,1为模式1
ET0=1;
TR0=1;
TH0=0xb1;
TL0=0xe0;
ET1=1;
TR1=1;
TH1 =0xff;
Disp_time_set=0x22;
TL1 = Disp_time_set;
P1=0xf8;
Time_H = 3; //时钟"时"(0~23)
Time_M = 20; //时钟"分"(0~59)
Time_S = 30; //时钟"秒"(0~59)
Time_ms = 0; //时钟"毫秒"(0~49) (每过20ms,+1)
T20ms_flag = 0; //20毫秒定时溢出标志(0=未溢出,1=溢出)
New_disp_flag = 1; //显示刷新使能标志=1(0=禁止,1=使能)
SET_EN_FLAG=0;
}
/***********************************************************************/
//计时处理程序(20ms 调用一次)
//功能: 1.计时
/***********************************************************************/
void time_cnt(void) //相关标志设置
{
T20ms_flag = 0; //20毫秒定时溢出标志=0
New_disp_flag = 1; //显示刷新使能标志=1(0=禁止,1=使能)
Time_ms++; //====计时
Mode_J++;
if (Mode_J > 1000)
{
Mode_J=0;
Disp_mode++;
if(Disp_mode==3)
Disp_mode=0;
}
if ( Time_ms > 49 ) //"毫秒"+1,结果>最大值?
{
Time_ms = 0 ; //"毫秒"=0
speednow=speed;
speed=0;
if ( ++Time_S > 59 ) //"秒"+1,结果>最大值?
{
Time_S = 0 ; //"秒"=0
if ( ++Time_M > 59 ) //"分"+1,结果>最大值?
{
Time_M = 0 ; //"分"=0
if ( ++Time_H > 23 ) //"时"+1,结果>最大值?
{
Time_H = 0 ; //"时"=0
}
}
}
}
}
/***********************************************************************/ //刷新显示
/***********************************************************************/ void new_display(void)
{
uchar i,j ;
New_disp_flag = 0 ; //显示刷新使能标志=0(0=禁止,1=使能) if ( SET_EN_FLAG == 0 )
{
//根据显示状态判断
switch(Disp_mode)//( Disp_mode )
{
//==================================
//显示状态0:模拟钟
//==================================
case 0:
//秒针定位
i = 2 * Time_S ; //秒针定位="秒"*3
S_Line = i + Time_S ;
S_Line = 180-S_Line ;
//时针定位
if ( Time_H > 11 ) i = Time_H -12 ; //"时"转换为12小时制
else i = Time_H ;
j = i * 16 - i ;
i = Time_M / 4 ;
H_Line = j + i ; //时针定位="时"*15+"分"/4
H_Line = 180-H_Line ; break;
//==================================
//显示状态1:数字钟
//==================================
case 1:
//计算显示数值内容
Disp_buffer[0] = Time_H / 10; //时
Disp_buffer[1] = Time_H % 10;
Disp_buffer[2] = 10; //":"
Disp_buffer[3] = Time_M / 10; //分
Disp_buffer[4] = Time_M % 10;
Disp_buffer[5] = 10; //":"
Disp_buffer[6] = Time_S / 10; //秒
Disp_buffer[7] = Time_S % 10;
Disp_buffer[8] = speednow/10; //电机转速
Disp_buffer[9] = speednow%10;
case 2:
//计算显示数值内容
Disp_buffer[0] = Time_H / 10; //时
Disp_buffer[1] = Time_H % 10;
Disp_buffer[2] = 10; //":"
Disp_buffer[3] = Time_M / 10; //分
Disp_buffer[4] = Time_M % 10;
Disp_buffer[5] = 10; //":"
Disp_buffer[6] = Time_S / 10; //秒
Disp_buffer[7] = Time_S % 10;
default:
break;
}
}
}
void main()
{
init(); //初始化
while(1)
{
if ( T20ms_flag ) time_cnt(); //如果20 毫秒定时溢出标志=1,
//则调用计时处理程序if ( New_disp_flag ) new_display(); //如果显示刷新使能标志=1,
//则刷新显示缓冲区}
}
void inter0() interrupt 0 using 1
{
Disp_Line = 0 ;
if ( Timer1_JSQ > 180 )
{
if ( Timer1_JSQ > 220 ) Disp_time_set = Disp_time_set - 0x1f ;
else if ( Timer1_JSQ > 200 ) Disp_time_set = Disp_time_set - 0x0f ;
else if ( Timer1_JSQ > 190 ) Disp_time_set = Disp_time_set - 0x08 ;
else Disp_time_set = Disp_time_set - 0x01 ;
if ( Disp_time_set < 0x0f ) Disp_time_set = 0x0f ; //钳位}
else if ( Timer1_JSQ < 180 )
{
if ( Timer1_JSQ < 140 ) Disp_time_set = Disp_time_set + 0x1f ;
else if ( Timer1_JSQ < 160 ) Disp_time_set = Disp_time_set + 0x0f ;
else if ( Timer1_JSQ < 170 ) Disp_time_set = Disp_time_set + 0x08 ;
else if ( Timer1_JSQ < 175 ) Disp_time_set = Disp_time_set + 0x04 ;
else if ( Timer1_JSQ < 178 ) Disp_time_set = Disp_time_set + 0x02 ;
else Disp_time_set = Disp_time_set + 0x01 ;
if ( Disp_time_set > 0xff ) Disp_time_set = 0xf0 ; //钳位}
Timer1_JSQ = 0 ; //TIMR1溢出计数器 = 0
speed=speed+1; //电机转速计数
l++;
m++;
if(m>96)m=0;
if(l>3)
{
l=0;
k++;
if(k>18)k=0;
}
}
void timer20ms(void) interrupt 1
{
TH0 = 0xb1;TL0 = 0xe0;
T20ms_flag = 1; //20毫秒定时溢出标志=1
}
void timer1(void) interrupt 3
{
int i,j;
P1=0xf0;
P2=0xff;
TH1 =0xff;TL1 =Disp_time_set; //0x22;
if ( ++Timer1_JSQ > 250 ) Timer1_JSQ = 250 ; //TIMR1 溢出计数器+1
if ( ++Disp_Line >= 180 ) Disp_Line = 0 ; //显示列计数器+1
switch(Disp_mode)
{
case 0:
P0=~LED_TAB_12369[Disp_Line];
//显示指针"时"
i = H_Line ;
j = H_Line ;
if ( ++i >= 180 ) i=0 ; //i+1,结果>=最大值,则清零
if ( --j >= 180 ) j=179; //(180-1);//j-1,结果为负,则重新赋值
if ( Disp_Line == H_Line )
{
P1=0xfc;
}
if ( Disp_Line == i || Disp_Line == j)
{
P1=0xfc;
}
//显示指针"分"
if ( Disp_Line == M_Line )
{
P1=0xfe;
}
//显示指针"秒"
if ( Disp_Line == S_Line )
{
P1=0xff;
}
break;
case 1:
if(Disp_Line<8)
{
P0=~LED_TAB_A0[Disp_buffer[3]*8+Disp_Line]; //显示分的个位}
else if(Disp_Line<16)
{
P0=~LED_TAB_A0[Disp_buffer[2]*8+Disp_Line-8];//显示“:”
}
else if(Disp_Line<24)
{
P0=~LED_TAB_A0[Disp_buffer[1]*8+Disp_Line-16];//显示秒十位
}
else if(Disp_Line<32)
{
P0=~LED_TAB_A0[Disp_buffer[0]*8+Disp_Line-24];//显示秒个位
}
else if(Disp_Line<48)
{
P0=~dis_code2[k][Disp_Line-32]; //显示心形动画
}
else if(Disp_Line<70)
{
P0=0xff;
}
else if(Disp_Line<78)
{
P2=num3[Disp_buffer[8]*16+Disp_Line-70]; //显“S”
P0=num3[Disp_buffer[8]*16+8+Disp_Line-70];
}
else if(Disp_Line<86)
{
P2=num3[Disp_buffer[9]*16+Disp_Line-78]; //显示“/”
P0=num3[Disp_buffer[9]*16+8+Disp_Line-78];
}
else if(Disp_Line<94)
{
P2=num3[160+Disp_Line-86]; //10*16=160 //显示“r”
P0=num3[168+Disp_Line-86];
}
else if(Disp_Line<102)
{
P2=num3[176+Disp_Line-94]; //11*16=176 //显示转速个位P0=num3[184+Disp_Line-94];
}
else if(Disp_Line<110)
{
P2=num3[192+Disp_Line-102]; //12*16=192 //显示转速十位}
else if(Disp_Line<132)
{
P0=0xff;
}
else if(Disp_Line<148)
{
P0=~dis_code2[k][Disp_Line-132]; //显示心形动画}
else if(Disp_Line<156)
{
P0=~LED_TAB_A0[Disp_buffer[7]*8+Disp_Line-148];//显示小时的十位}
else if(Disp_Line<164)
{
P0=~LED_TAB_A0[Disp_buffer[6]*8+Disp_Line-156];//显示小时的个位}
else if(Disp_Line<172)
{
P0=~LED_TAB_A0[Disp_buffer[5]*8+Disp_Line-164];//显示“:”
}
else if(Disp_Line<180)
{
P0=~LED_TAB_A0[Disp_buffer[4]*8+Disp_Line-172];//显示分钟的十位}
break;
case 2:
if(Disp_Line<8)
{
P0=num1[Disp_buffer[3]*8+Disp_Line]; //显示分钟的个位
P2=num2[Disp_buffer[3]*8+Disp_Line];
}
else if(Disp_Line<16)
{
P0=num1[Disp_buffer[2]*8+Disp_Line-8]; //显示“:”
P2=num2[Disp_buffer[2]*8+Disp_Line-8];
}
else if(Disp_Line<24)
{
P0=num1[Disp_buffer[1]*8+Disp_Line-16]; //显示秒的十位
P2=num2[Disp_buffer[1]*8+Disp_Line-16];
}
}
else if(Disp_Line<48)
{
P0=~dis_code1[k][Disp_Line-32];//P0=0xff; //显示心形动画}
else if(Disp_Line<50)
{
P0=0xff;
}
else if(Disp_Line<130)
{
P2=hanzi1[Disp_Line-50+m]; //显示“郑州大学西亚斯国际学学院”
P0=hanzi2[Disp_Line-50+m];
}
else if(Disp_Line<132)
{
P0=0xff;
}
else if(Disp_Line<148)
{
P0=~dis_code1[k][Disp_Line-132]; //显示心形动画}
else if(Disp_Line<156)
{
P0=num1[Disp_buffer[7]*8+Disp_Line-148]; //显示小时的十位
P2=num2[Disp_buffer[7]*8+Disp_Line-148];
}
else if(Disp_Line<164)
{
P0=num1[Disp_buffer[6]*8+Disp_Line-156]; //显示小时的个位
P2=num2[Disp_buffer[6]*8+Disp_Line-156];
}
else if(Disp_Line<172)
{
P0=num1[Disp_buffer[5]*8+Disp_Line-164]; //显示“:”
P2=num2[Disp_buffer[5]*8+Disp_Line-164];
}
else if(Disp_Line<180)
{
P0=num1[Disp_buffer[4]*8+Disp_Line-172]; //显示分钟的十位
P2=num2[Disp_buffer[4]*8+Disp_Line-172];
}
break;
default:
break;
}
}。