STC11F04单片机制作的32灯摇摇棒
时间:11-30
来源:互联网
点击:
说到摇摇棒,大家应该不陌生,但这款摇摇棒,用了一片20脚的STC11F04单片机,控制32只发光二极管,能显示13组左右的字或者图片,能显示高32宽64的图像和字体任意,开机后自动切换每一组字,按了一下背部的开关后变成手动切换!能根据自己的喜好用字模软件编写各种各样的字体和图片,方法很简单!只要有单片机的一点基础就可以随意的玩耍,送给朋友和喜欢的人是件不错的礼物哦!此摇摇棒其实是没限制的,可以显示高32宽很长的字和图片,只不过麻烦的是要手晃得大一点而已!所以通常都限制在合适的范围!资料来源于网络,作者:张国荣。
/*********外部接口定义**********/
#define uchar unsigned char
#define uint unsigned int //宏定义
#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; //KY作用在后面说明
uchar BUFF; //缓存
/*********全局变量定义**********/
unsigned long int TimeCount=0;
unsigned int DelayN=80, //延时临时计数
DelayTime=80; //每次延时的周期个数
unsigned char key;
/**********************************************/
void delay(unsigned char n);
void DelayMs(void);
/*******************************************/
unsigned char code text1[] = {
0xEF,0x7F,0xEF,0xBC,0x0F,0xDD,0xE0,0xEB,0xEF,0xF3,0x0F,0x8C,0x7F,0xDF,0x7D,0xFF,0x7D,0xBF,0x7D,0x7F,0x0D,0x80,0x75,0xFF,0x79,0xFF,0x7D,0xFF,0x7F,0xFF,0xFF,0xFF,/*"好",0*/
0xEF,0x7F,0xEF,0xBC,0x0F,0xDD,0xE0,0xEB,0xEF,0xF3,0x0F,0x8C,0x7F,0xDF,0x7D,0xFF,0x7D,0xBF,0x7D,0x7F,0x0D,0x80,0x75,0xFF,0x79,0xFF,0x7D,0xFF,0x7F,0xFF,0xFF,0xFF,/*"好",1*/
0xBF,0xFF,0xCF,0xFD,0xEF,0xFD,0xED,0xFD,0xA3,0xFD,0xAB,0xFD,0xAF,0x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)延时子程序***************/
void DelayUs(uint N)
{
uint x;
for(x=0; x<=N;x++);
}
/******************************************/
void main()
{
AUXR=0x80;
CLK_div=0;
EX0=1; //开放外部中断0
IT0=1; //中断0为边沿触发方式
IP=0x02; //设置中断优先级
TMOD=0x02; //定时器0方式2,8位重装载
TH0=0x80; //设定定时器初值
TL0=0x80;
KY=0;
EA=1; //开放中断
ET0=1; //开放定时器1中断
TR0=1; //启动定时器0,开始计时*/
key=0; //初始化显示第一组文字
P1M0=0x55; //0101 0101 /P1.0 P1 .2 P1.4 P1.6推挽输出
P1M1=0xAA;
while(1){//等待中断
if(key1==0){
DelayUs(200); //按键去抖处理
if(key1==0){ //有键按下
key++; //更换下一幅图片
if(key==5) key=0; //图片循环显示
while(key1==0); //等待按键释放
}
}
}
}
/*********文字显示子程序**********/
void display_word(unsigned char code *text)
{ char i,j=2; //j为图片起始位置 2 为第3个开始是图片 如果要显示32*32大字 也属于图片格式
DelayUs(5000);
for(i=0;i<64;i++)
{
P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
P3M1=0x1B;
if(key>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
delay(1);
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
delay(1);
P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
P3M1=0x1B; //0001 1011
if(key>j)
BUFF=(*(text+i*4+2));
else
BUFF=(*(text+128+i*2));
led3=0;
P1=~BUFF>>1;
P3M0=0x08; //0000 1000 //P3.3推挽输出 P3 .0 P3.1 P3.4输入高阻
P3M1=0x13; //0001 0011
delay(1);
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
delay(1);
P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
P3M1=0x1B;
if(key>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
delay(1);
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
delay(1);
P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
P3M1=0x1B; //0001
if(key>j)
BUFF=(*(text+i*4));
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
delay(1);
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
delay(1);
} }
/*********显示内容选择子程序**********/
void display(unsigned char t)
{
switch (t){ //通过按键选择显示内容
case 0: {display_word(text1);}break;
case 1: {display_word(text2);}break;
case 2: {display_word(text3);}break;
case 3: {display_word(text4);}break;
case 4: {display_word(text5);}break;
//default:{display_word(text1);}
}}
/***************************************/
/*********延时子程序**********/
void delay(unsigned char n)
{
for(;n>0;n--){
DelayN=DelayTime;
while (DelayN);
}
}
/*********中断子程序**********/
void int0() interrupt 0 //使用外部中断0
{
KY=~KY;
if(KY==0)
{
DelayTime=TimeCount/1580;
TimeCount=0; //延时周期计数清零
display(key); //根据按键选择循环显示文字
}
}
void timer0() interrupt 1 //定时器0中断子程序
{
TimeCount++;
if (DelayN!=0)
DelayN--;
}
/*********外部接口定义**********/
#define uchar unsigned char
#define uint unsigned int //宏定义
#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; //KY作用在后面说明
uchar BUFF; //缓存
/*********全局变量定义**********/
unsigned long int TimeCount=0;
unsigned int DelayN=80, //延时临时计数
DelayTime=80; //每次延时的周期个数
unsigned char key;
/**********************************************/
void delay(unsigned char n);
void DelayMs(void);
/*******************************************/
unsigned char code text1[] = {
0xEF,0x7F,0xEF,0xBC,0x0F,0xDD,0xE0,0xEB,0xEF,0xF3,0x0F,0x8C,0x7F,0xDF,0x7D,0xFF,0x7D,0xBF,0x7D,0x7F,0x0D,0x80,0x75,0xFF,0x79,0xFF,0x7D,0xFF,0x7F,0xFF,0xFF,0xFF,/*"好",0*/
0xEF,0x7F,0xEF,0xBC,0x0F,0xDD,0xE0,0xEB,0xEF,0xF3,0x0F,0x8C,0x7F,0xDF,0x7D,0xFF,0x7D,0xBF,0x7D,0x7F,0x0D,0x80,0x75,0xFF,0x79,0xFF,0x7D,0xFF,0x7F,0xFF,0xFF,0xFF,/*"好",1*/
0xBF,0xFF,0xCF,0xFD,0xEF,0xFD,0xED,0xFD,0xA3,0xFD,0xAB,0xFD,0xAF,0xBD,0xAE,0x7D,0xA1,0x80,0x2B,0xFD,0xAF,0xFD,0xE7,0xFD,0xA8,0xFD,0xCD,0xFD,0x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0x9F,0x7F,0x9E,0x3F,0xDF,0x7F,0x9E,0x3F,0xDF,0x7C,0x9E,0x3F,0xDF,0x60,0x00,0x00,0xDF,0x67,0x9E,0x3F,0xCF,0x7F,0x9E,0x3F,0xCF,0x7F,0x9E,0x3F,
0xCF,0x7F,0x9E,0x3F,0xEF,0x67,0x9E,0x3F,0xE7,0x61,0x9E,0x3F,0x67,0x78,0x9E,0x81,0x27,0xFE,0x9E,0xC1,0xFF,0xFF,0x9F,0xFF,0xFF,0xFF,0x9F,0xFF,0xFF,0xFF,0xFF,0xFF,/*"摇",0*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF9,0xFF,0xFF,0x0F,0xF8,0x3F,0x7F,0x80,0xFF,0x9F,0xFF,0xFF,0xFF,0xC7,0xFF,0xFF,0xFF,0xE1,0x07,0x00,0x00,0xF8,0x07,0x00,0x00,0xFF,
0xFF,0x1F,0x7F,0xFE,0xFF,0xC3,0xFF,0xF8,0x7F,0xF0,0xFF,0xE1,0x3F,0xFE,0xFF,0xC7,0xFF,0xFF,0xFF,0xDF,0x9F,0xFF,0xFF,0xFF,0x9F,0xFF,0xFF,0xFF,0x9F,0xFF,0xFF,0xFF,
0x9F,0xFF,0xFF,0xDF,0x9F,0xFF,0xFF,0xDF,0x9F,0xFF,0xFF,0x9F,0x9F,0xFF,0xFF,0x9F,0x9F,0xFF,0xFF,0xBF,0x9F,0xFF,0xFF,0xBF,0x9F,0xFF,0xFF,0xBF,0x9F,0xFF,0xFF,0xBF,
0x1F,0x00,0x00,0x80,0x1F,0x00,0x00,0xC0,0x9F,0xFF,0xFF,0xFF,0x9F,0xFF,0xFF,0xFF,0x9F,0xFF,0xFF,0xFF,0x9F,0xFF,0xFF,0xFF,0xBF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,/*"灯",1*/
};
/***********n(us)延时子程序***************/
void DelayUs(uint N)
{
uint x;
for(x=0; x<=N;x++);
}
/******************************************/
void main()
{
AUXR=0x80;
CLK_div=0;
EX0=1; //开放外部中断0
IT0=1; //中断0为边沿触发方式
IP=0x02; //设置中断优先级
TMOD=0x02; //定时器0方式2,8位重装载
TH0=0x80; //设定定时器初值
TL0=0x80;
KY=0;
EA=1; //开放中断
ET0=1; //开放定时器1中断
TR0=1; //启动定时器0,开始计时*/
key=0; //初始化显示第一组文字
P1M0=0x55; //0101 0101 /P1.0 P1 .2 P1.4 P1.6推挽输出
P1M1=0xAA;
while(1){//等待中断
if(key1==0){
DelayUs(200); //按键去抖处理
if(key1==0){ //有键按下
key++; //更换下一幅图片
if(key==5) key=0; //图片循环显示
while(key1==0); //等待按键释放
}
}
}
}
/*********文字显示子程序**********/
void display_word(unsigned char code *text)
{ char i,j=2; //j为图片起始位置 2 为第3个开始是图片 如果要显示32*32大字 也属于图片格式
DelayUs(5000);
for(i=0;i<64;i++)
{
P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
P3M1=0x1B;
if(key>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
delay(1);
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
delay(1);
P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
P3M1=0x1B; //0001 1011
if(key>j)
BUFF=(*(text+i*4+2));
else
BUFF=(*(text+128+i*2));
led3=0;
P1=~BUFF>>1;
P3M0=0x08; //0000 1000 //P3.3推挽输出 P3 .0 P3.1 P3.4输入高阻
P3M1=0x13; //0001 0011
delay(1);
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
delay(1);
P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
P3M1=0x1B;
if(key>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
delay(1);
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
delay(1);
P3M0=0x00; //0000 0000 //P3.0推挽输出 P3 .1 P3.3 P3.4输入高阻
P3M1=0x1B; //0001
if(key>j)
BUFF=(*(text+i*4));
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
delay(1);
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
delay(1);
} }
/*********显示内容选择子程序**********/
void display(unsigned char t)
{
switch (t){ //通过按键选择显示内容
case 0: {display_word(text1);}break;
case 1: {display_word(text2);}break;
case 2: {display_word(text3);}break;
case 3: {display_word(text4);}break;
case 4: {display_word(text5);}break;
//default:{display_word(text1);}
}}
/***************************************/
/*********延时子程序**********/
void delay(unsigned char n)
{
for(;n>0;n--){
DelayN=DelayTime;
while (DelayN);
}
}
/*********中断子程序**********/
void int0() interrupt 0 //使用外部中断0
{
KY=~KY;
if(KY==0)
{
DelayTime=TimeCount/1580;
TimeCount=0; //延时周期计数清零
display(key); //根据按键选择循环显示文字
}
}
void timer0() interrupt 1 //定时器0中断子程序
{
TimeCount++;
if (DelayN!=0)
DelayN--;
}
STC11F04单片机制摇摇 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)