STC11F02E内容较小 如果需要显示的图片多一点 可以改内存大的4E或者5E;
程序,步骤简单。
话不多出,附上图片
Altium Designer画的原理图和PCB图如下:(51hei附件中可下载工程文件)
单片机源程序如下:
- #include "yyb.h"
- #define out P1 //数据输出端口
- sbit led1=P3^0; //第1组LED
- sbit led2=P3^1; //第2组LED
- sbit led3=P3^3; //第3组LED
- sbit led4=P3^4; //第4组LED
- sbit key1=P3^5; //按键输入
- sbit p3_2=P3^2;
- uchar KY,num; //KY作用在后面说明
- uchar BUFF; //缓存
- /*********全局变量定义**********/
- unsigned long int TimeCount=0;
- unsigned int DelayN=1, //延时临时计数
- DelayTime=1; //每次延时的周期个数
- unsigned char key,keyy;
- void DelayUs(uint N)
- {
- uint x;
- for(x=0; x<=N;x++);
- }
- void display_word(unsigned char code *text)
- {
- unsigned char i,j=2;
-
- DelayUs(50); //因为第一第二半圈不会是完整的180 所以用延时来补偿形成一个完整的圆 可适当修改
-
- for(i=0;i<64;i++) //第一半圈显示程序
- {
- P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1B;
- if((key>=j)||(keyy>=j))
- BUFF=(*(text+i*4+3));
- else
- BUFF=(*(text+128+i*2+1));
- led4=0;
- P1=~BUFF>>1;
- P3M0=0x10; //0001 0000 //P3.4推挽输出 P3 .0 P3.3 P3.1输入高阻
- P3M1=0x0B; //0000 1011
-
- P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1B; //0001 1011
- led4=1;
- P1=BUFF; //01010101 1357
- P3M0=0x10; //0001 0000 //P3.4推挽输出 P3 .0 P3.3 P3.1输入高阻
- P3M1=0x0B; //0000 1011
-
- P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1B; //0001 1011
-
- if((key>=j)||(keyy>=j))
- BUFF=(*(text+i*4+2));
- else
- BUFF=(*(text+128+i*2+0));
- led3=0;
- P1=~BUFF>>1;
- P3M0=0x08; //0000 1000 //P3.3推挽输出 P3 .0 P3.1 P3.4输入高阻
- P3M1=0x13; //0001 0011
-
- P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1B; //0001 1011
- led3=1;
- P1=BUFF; //01010101 1357
- P3M0=0x08; //0000 1000 //P3.3推挽输出 P3 .0 P3.1 P3.4输入高阻
- P3M1=0x13; //0001 0011
-
- P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1B;
-
- if((key>=j)||(keyy>=j))
- BUFF=(*(text+i*4+1));
- else
- BUFF=(*(text+i*2+1));
- led2=0;
- P1=~BUFF>>1;
- P3M0=0x02; //0000 0010 //P3.1推挽输出 P3 .0 P3.3 P3.4输入高阻
- P3M1=0x19; //0001 1001
-
- P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1B; //0001 1011
- led2=1;
- P1=BUFF; //01010101 1357
- P3M0=0x02; //0000 0010 //P3.1推挽输出 P3 .0 P3.3 P3.4输入高阻
- P3M1=0x19; //0001 1001
-
- P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1B; //0001
- if((key>=j)||(keyy>=j))
- BUFF=(*(text+i*4+0));
- else
- BUFF=(*(text+i*2));
- led1=0;
- P1=~BUFF>>1;
- P3M0=0x01; //0000 0001 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1A; //0001 1010
-
- P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1B; //0001 1011
- led1=1;
- P1=BUFF; //01010101 1357
- P3M0=0x01; //0000 0001 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1A; //0001 1010
-
- }
- for(i=0;i<64;i++) //第二半圈显示程序
- {
-
- P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1B;
- if((key>=j)||(keyy>=j))
- BUFF=(*(text+i*4+3+256));
- else
- BUFF=(*(text+128+i*2+1+256));
- led4=0;
- P1=~BUFF>>1;
- P3M0=0x10; //0001 0000 //P3.4推挽输出 P3 .0 P3.3 P3.1输入高阻
- P3M1=0x0B; //0000 1011
-
- P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1B; //0001 1011
- led4=1;
- P1=BUFF; //01010101 1357
- P3M0=0x10; //0001 0000 //P3.4推挽输出 P3 .0 P3.3 P3.1输入高阻
- P3M1=0x0B; //0000 1011
-
- P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1B; //0001 1011
-
- if((key>=j)||(keyy>=j))
- BUFF=(*(text+i*4+2+256));
- else
- BUFF=(*(text+128+i*2+0+256));
- led3=0;
- P1=~BUFF>>1;
- P3M0=0x08; //0000 1000 //P3.3推挽输出 P3 .0 P3.1 P3.4输入高阻
- P3M1=0x13; //0001 0011
-
- P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1B; //0001 1011
- led3=1;
- P1=BUFF; //01010101 1357
- P3M0=0x08; //0000 1000 //P3.3推挽输出 P3 .0 P3.1 P3.4输入高阻
- P3M1=0x13; //0001 0011
-
- P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1B;
-
- if((key>=j)||(keyy>=j))
- BUFF=(*(text+i*4+1+256));
- else
- BUFF=(*(text+i*2+1+256));
- led2=0;
- P1=~BUFF>>1;
- P3M0=0x02; //0000 0010 //P3.1推挽输出 P3 .0 P3.3 P3.4输入高阻
- P3M1=0x19; //0001 1001
-
- P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1B; //0001 1011
- led2=1;
- P1=BUFF; //01010101 1357
- P3M0=0x02; //0000 0010 //P3.1推挽输出 P3 .0 P3.3 P3.4输入高阻
- P3M1=0x19; //0001 1001
-
- P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1B; //0001
- if((key>=j)||(keyy>=j))
- BUFF=(*(text+i*4+0+256));
- else
- BUFF=(*(text+i*2+256));
- led1=0;
- P1=~BUFF>>1;
- P3M0=0x01; //0000 0001 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1A; //0001 1010
-
- P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1B; //0001 1011
- led1=1;
- P1=BUFF; //01010101 1357
- P3M0=0x01; //0000 0001 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
- P3M1=0x1A; //0001 1010
-
- }
- }
- /*****************************************/
- void display(unsigned char y)
- {
- switch (y){ //显示内容的先后
- case 0: {display_word(text0);}break;
- case 1: {display_word(text1);}break;
- // case 2: {display_word(text2);}break;
- // case 3: {display_word(text3);}break;
- }
- }
- /***************************************/
- /*********延时子程序**********/
- void yyv_init(void) //程序初始化
- {
- AUXR=0x80;
- CLK_DIV=1;
- EX0=1; //开放外部中断0
- IT0=1; //中断0为边沿触发方式
- IP=0x02; //设置中断优先级
- TMOD=0x02; //定时器0方式2,8位重装载
- TH0=0x00; //设定定时器初值 //8080
- TL0=0x01;
- KY=0;
- EA=1; //开放中断
- ET0=1; //开放定时器0中断
- TR0=1; //启动定时器0,开始计时*/
- key=0; //初始化显示第一组文字
- keyy=0;
- P1M0=0x55; //0101 0101 /P1.0 P1 .2 P1.4 P1.6推挽输出
- P1M1=0xAA; //1010 1010
- }
- void timer0() interrupt 1 //定时器0中断子程序
- {
- TimeCount++;
- if (DelayN!=0)DelayN--;
- }
- //显示数据段
- unsigned char code text0[]={
- 0xFF,0x7F,0xEF,0xBF,0xEF,0xDF,0xEF,0xE7,0xE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7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,//
- 0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0xFF,0xFF,//?2
- 0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,//
- 0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0xFF,0xFF,//?3 由于下半部分显示字体看不清楚 所以用来字符来修饰
-
- 0xFF,0xFF,0xFF,0xFF,0x07,0xE0,0x77,0xF7,0x77,0xF7,0x77,0xF7,0x77,0xF7,0x00,0x80,
- 0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x77,0x07,0x60,0xFF,0x7F,0xFF,0x0F,0xFF,0xFF,/*"电",0*/
- 0x7F,0xFF,0x7D,0xFF,0x7D,0xFF,0x7D,0xFF,0x7D,0xFF,0x7D,0xBF,0x7D,0x7F,0x1D,0x80,
- 0x5D,0xFF,0x6D,0xFF,0x75,0xFF,0x79,0xFF,0x7D,0xFF,0x7F,0xFF,0x7F,0xFF,0xFF,0xFF,/*"子",1*/
- 0xEF,0xFF,0xEF,0xFF,0x00,0x00,0xEF,0xFF,0xEF,0xFB,0xFF,0x7D,0x6F,0xBE,0xEF,0xCF,
- 0x00,0xF0,0xEF,0xBF,0xEF,0x7F,0x0F,0x80,0x7F,0xFF,0xFF,0xFE,0xFF,0xF9,0xFF,0xFF,/*"协",2*/
- 0xBF,0xFF,0xBF,0xFD,0xDF,0xBD,0xDF,0x1D,0xAF,0xAD,0xB7,0xB5,0xBB,0xB9,0xBC,0xBD,
- 0xBB,0xBD,0xB7,0xBD,0xAF,0xAD,0xDF,0x9D,0xDF,0x3D,0xBF,0xFD,0xBF,0xFF,0xFF,0xFF,/*"会",3*/ //这是第2半圈 组成一个圆
-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1*/
- 0xDF,0xFF,0xEF,0xEF,0xD3,0xEF,0x58,0xEC,0xD3,0xED,0xCB,0xED,0xDB,0xED,0xCB,0xED,//
- 0xD7,0xED,0xD8,0xED,0xDB,0xAD,0x13,0x7C,0xEB,0xBD,0xFB,0xC1,0xFB,0xFF,0xFF,0xFF,//笃2*/
- 0xFF,0xFD,0xEF,0xFE,0x77,0xFF,0x3B,0x00,0xCC,0xFF,0xFF,0xFF,0xBF,0xFF,0xBD,0xFF,//
- 0xBD,0xBF,0xBD,0x7F,0x3D,0x80,0xBD,0xFF,0xBD,0xFF,0xBD,0xFF,0xBF,0xFF,0xFF,0xFF,//行3*/
- 0xBF,0xFD,0xBF,0xFD,0x7F,0xFE,0x0F,0xF0,0x7F,0xFE,0xBF,0xFD,0xBF,0xFD,0xFF,0xFF,//*0
- 0xBF,0xFD,0xBF,0xFD,0x7F,0xFE,0x0F,0xF0,0x7F,0xFE,0xBF,0xFD,0xBF,0xFD,0xFF,0xFF,//*1
- 0xBF,0xFD,0xBF,0xFD,0x7F,0xFE,0x0F,0xF0,0x7F,0xFE,0xBF,0xFD,0xBF,0xFD,0xFF,0xFF,//*2
- 0xBF,0xFD,0xBF,0xFD,0x7F,0xFE,0x0F,0xF0,0x7F,0xFE,0xBF,0xFD,0xBF,0xFD,0xFF,0xFF,//*3
- 0xBF,0xFD,0xBF,0xFD,0x7F,0xFE,0x0F,0xF0,0x7F,0xFE,0xBF,0xFD,0xBF,0xFD,0xFF,0xFF,//*4
- 0xBF,0xFD,0xBF,0xFD,0x7F,0xFE,0x0F,0xF0,0x7F,0xFE,0xBF,0xFD,0xBF,0xFD,0xFF,0xFF,//*5
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
旋转摇摇棒.7z
(671.22 KB, 下载次数: 114)
|