#include <REG52.H>
#include "SoundPlay.h"
unsigned char RunMode;
//**********************************System Fuction*************************************************
void Delay1ms(unsigned int count)
{
unsigned int i,j;
for(i=0;i<count;i++)
for(j=0;j<120;j++);
}
unsigned char code LEDDisplayCode[] = { 0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8, //0~7
0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E,0xFF};
void Display(unsigned char Value)
{
P3 = LEDDisplayCode[Value];
}
void LEDFlash(unsigned char Count)
{
unsigned char i;
bit Flag;
for(i = 0; i<Count;i++)
{
Flag = !Flag;
if(Flag)
Display(RunMode);
else
Display(0x10);
Delay1ms(100);
}
Display(RunMode);
}
unsigned char GetKey(void)
{
unsigned char KeyTemp,CheckValue,Key = 0x00;
CheckValue = P2&0x32;
if(CheckValue==0x32)
return 0x00;
Delay1ms(10);
KeyTemp = P2&0x32;
if(KeyTemp==CheckValue)
return 0x00;
if(!(CheckValue&0x02))
Key|=0x01;
if(!(CheckValue&0x10))
Key|=0x02;
if(!(CheckValue&0x20))
Key|=0x04;
return Key;
}
unsigned int Timer0Count,SystemSpeed,SystemSpeedIndex;
void InitialTimer2(void)
{
T2CON = 0x00; //16 Bit Auto-Reload Mode
TH2 = RCAP2H = 0xFC; //重装值,初始值 TL2 = RCAP2L = 0x18;
ET2=1; //定时器 2 中断允许
TR2 = 1; //定时器 2 启动
EA=1;
}
unsigned int code SpeedCode[]={ 1, 2, 3, 5, 8, 10, 14, 17, 20, 30,
40, 50, 60, 70, 80, 90, 100, 120, 140, 160,
180, 200, 300, 400, 500, 600, 700, 800, 900,1000};//30
void SetSpeed(unsigned char Speed)
{
SystemSpeed =SpeedCode[Speed];
}
void LEDShow(unsigned int LEDStatus)
{
P1 = ~(LEDStatus&0x00FF);
P0 = ~((LEDStatus>>8)&0x00FF);
}
void InitialCPU(void)
{
RunMode = 0x00;
Timer0Count = 0;
SystemSpeedIndex = 9;
P1 = 0x00;
P0 = 0x00;
P2 = 0xFF;
P3 = 0x00;
Delay1ms(500);
P1 = 0xFF;
P0 = 0xFF;
P2 = 0xFF;
P3 = 0xFF;
SetSpeed(SystemSpeedIndex);
Display(RunMode);
}
//Mode 0
unsigned int LEDIndex = 0;
bit LEDDirection = 1,LEDFlag = 1;
void Mode_0(void)
{
LEDShow(0x0001<<LEDIndex);
LEDIndex = (LEDIndex+1)%16;
}
//Mode 1
void Mode_1(void)
{
LEDShow(0x8000>>LEDIndex);
LEDIndex = (LEDIndex+1)%16;
}
//Mode 2
void Mode_2(void)
{
if(LEDDirection)
LEDShow(0x0001<<LEDIndex);
else
LEDShow(0x8000>>LEDIndex);
if(LEDIndex==15)
LEDDirection = !LEDDirection;
LEDIndex = (LEDIndex+1)%16;
}
//Mode 3
void Mode_3(void)
{
if(LEDDirection)
LEDShow(~(0x0001<<LEDIndex));
else
LEDShow(~(0x8000>>LEDIndex));
if(LEDIndex==15)
LEDDirection = !LEDDirection;
LEDIndex = (LEDIndex+1)%16;
}
//Mode 4
void Mode_4(void)
{
if(LEDDirection)
{
if(LEDFlag)
LEDShow(0xFFFE<<LEDIndex);
else
LEDShow(~(0x7FFF>>LEDIndex));
}
else
{
if(LEDFlag)
LEDShow(0x7FFF>>LEDIndex);
else
LEDShow(~(0xFFFE<<LEDIndex));
}
if(LEDIndex==15)
{
LEDDirection = !LEDDirection;
if(LEDDirection) LEDFlag = !LEDFlag;
}
LEDIndex = (LEDIndex+1)%16;
}
//Mode 5
void Mode_5(void)
{
if(LEDDirection)
LEDShow(0x000F<<LEDIndex);
else
LEDShow(0xF000>>LEDIndex);
if(LEDIndex==15)
LEDDirection = !LEDDirection;
LEDIndex = (LEDIndex+1)%16;
}
//Mode 6
void Mode_6(void)
{
if(LEDDirection)
LEDShow(~(0x000F<<LEDIndex));
else
LEDShow(~(0xF000>>LEDIndex));
if(LEDIndex==15)
LEDDirection = !LEDDirection;
LEDIndex = (LEDIndex+1)%16;
}
//Mode 7
void Mode_7(void)
{
if(LEDDirection)
LEDShow(0x003F<<LEDIndex);
else
LEDShow(0xFC00>>LEDIndex);
if(LEDIndex==9)
LEDDirection = !LEDDirection;
LEDIndex = (LEDIndex+1)%10;
}
//Mode 8
void Mode_8(void)
{
LEDShow(++LEDIndex);
}
void Timer0EventRun(void)
{
if(RunMode==0x00)
{
Mode_0();
}
else if(RunMode ==0x01)
{
Mode_1();
}
else if(RunMode ==0x02)
{
Mode_2();
}
else if(RunMode ==0x03)
{
Mode_3();
}
else if(RunMode ==0x04)
{
Mode_4();
}
else if(RunMode ==0x05)
{
Mode_5();
}
else if(RunMode ==0x06)
{
Mode_6();
}
else if(RunMode ==0x07)
{
Mode_7();
}
else if(RunMode ==0x08)
{
Mode_8();
}
}
void Timer2(void) interrupt 5 using 3
{
TF2 = 0; //中断标志清除( Timer2 必须软件清标志!)
if(++Timer0Count>=SystemSpeed)
{
Timer0Count = 0;
Timer0EventRun();
}
}
unsigned char MusicIndex = 0;
void KeyDispose(unsigned char Key)
{
if(Key&0x01)
{
LEDDirection = 1;
LEDIndex = 0;
LEDFlag = 1;
RunMode = (RunMode+1)%10;
Display(RunMode);
if(RunMode==0x09)
TR2 = 0;
else
TR2 = 1;
}
if(Key&0x02)
{
if(RunMode==0x09)
{
MusicIndex =(MusicIndex+MUSICNUMBER-1)%MUSICNUMBER;
}
else
{
if(SystemSpeedIndex>0)
{
--SystemSpeedIndex;
SetSpeed(SystemSpeedIndex);
}
else
{
LEDFlash(6);
}
}
}
if(Key&0x04)
{
if(RunMode==0x09)
{
MusicIndex =(MusicIndex+1)%MUSICNUMBER;
}
else
{
if(SystemSpeedIndex<28)
{
++SystemSpeedIndex;
SetSpeed(SystemSpeedIndex);
}
else
{
LEDFlash(6);
}
}
}
}
//*****************************Music******************************************************
//挥着翅膀的女孩
unsigned char code Music_Girl[]={ 0x17,0x02, 0x17,0x03, 0x18,0x03, 0x19,0x02, 0x15,0x03,
0x16,0x03, 0x17,0x03, 0x17,0x03, 0x17,0x03, 0x18,0x03,
0x19,0x02, 0x16,0x03, 0x17,0x03, 0x18,0x02, 0x18,0x03,
0x17,0x03, 0x15,0x02, 0x18,0x03, 0x17,0x03, 0x18,0x02,
0x10,0x03, 0x15,0x03, 0x16,0x02, 0x15,0x03, 0x16,0x03,
0x17,0x02, 0x17,0x03, 0x18,0x03, 0x19,0x02, 0x1A,0x03,
0x1B,0x03, 0x1F,0x03, 0x1F,0x03, 0x17,0x03, 0x18,0x03,
0x19,0x02, 0x16,0x03, 0x17,0x03, 0x18,0x03, 0x17,0x03,
0x18,0x03, 0x1F,0x03, 0x1F,0x02, 0x16,0x03, 0x17,0x03,
0x18,0x03, 0x17,0x03, 0x18,0x03, 0x20,0x03, 0x20,0x02,
0x1F,0x03, 0x1B,0x03, 0x1F,0x66, 0x20,0x03, 0x21,0x03,
0x20,0x03, 0x1F,0x03, 0x1B,0x03, 0x1F,0x66, 0x1F,0x03,
0x1B,0x03, 0x19,0x03, 0x19,0x03, 0x15,0x03, 0x1A,0x66,
0x1A,0x03, 0x19,0x03, 0x15,0x03, 0x15,0x03, 0x17,0x03,
0x16,0x66, 0x17,0x04, 0x18,0x04, 0x18,0x03, 0x19,0x03,
0x1F,0x03, 0x1B,0x03, 0x1F,0x66, 0x20,0x03, 0x21,0x03,
0x20,0x03, 0x1F,0x03, 0x1B,0x03, 0x1F,0x66, 0x1F,0x03,
0x1B,0x03, 0x19,0x03, 0x19,0x03, 0x15,0x03, 0x1A,0x66,
0x1A,0x03, 0x19,0x03, 0x19,0x03, 0x1F,0x03, 0x1B,0x03,
0x1F,0x00, 0x1A,0x03, 0x1A,0x03, 0x1A,0x03, 0x1B,0x03,
0x1B,0x03, 0x1A,0x03, 0x19,0x03, 0x19,0x02, 0x17,0x03,
0x15,0x17, 0x15,0x03, 0x16,0x03, 0x17,0x03, 0x18,0x03,
0x17,0x04, 0x18,0x0E, 0x18,0x03, 0x17,0x04, 0x18,0x0E,
0x18,0x66, 0x17,0x03, 0x18,0x03, 0x17,0x03, 0x18,0x03,
0x20,0x03, 0x20,0x02, 0x1F,0x03, 0x1B,0x03, 0x1F,0x66,
0x20,0x03, 0x21,0x03, 0x20,0x03, 0x1F,0x03, 0x1B,0x03,
0x1F,0x66, 0x1F,0x04, 0x1B,0x0E, 0x1B,0x03, 0x19,0x03,
0x19,0x03, 0x15,0x03, 0x1A,0x66, 0x1A,0x03, 0x19,0x03,
0x15,0x03, 0x15,0x03, 0x17,0x03, 0x16,0x66, 0x17,0x04,
0x18,0x04, 0x18,0x03, 0x19,0x03, 0x1F,0x03, 0x1B,0x
没有合适的资源?快使用搜索试试~ 我知道了~
Proteus经典例子
共129个文件
bak:15个
dbk:9个
lst:8个
需积分: 0 35 下载量 141 浏览量
2009-05-16
22:58:57
上传
评论
收藏 946KB RAR 举报
温馨提示
Proteus 经典例子
资源推荐
资源详情
资源评论
收起资源包目录
Proteus经典例子 (129个子文件)
STARTUP.A51 5KB
STARTUP.A51 5KB
DS1302.h.bak 6KB
HurricaneLamp_Uv2.Bak 2KB
DS1302_Uv2.Bak 2KB
PlayMusic_Uv2.Bak 2KB
FlashLED_Uv2.Bak 2KB
Max7221_Uv2.Bak 2KB
LCD1602_Opt.Bak 2KB
HurricaneLamp_Opt.Bak 1KB
PlayMusic_Opt.Bak 1KB
FlashLED_Opt.Bak 1KB
LiWan_Opt.Bak 1KB
DS1302_Opt.Bak 1024B
Max7221_Opt.Bak 1022B
Max7221.h.bak 540B
LiWan_Uv2.Bak 0B
LiWan.BMP 2.67MB
hurricanelamp.bmp 2.67MB
Max7221.BMP 2.67MB
DS1302.BMP 1.34MB
LCD1602.BMP 1.34MB
flashled.bmp 1.34MB
PlayMusic.BMP 1.34MB
LiWan.c 14KB
PlayMusic.c 9KB
HurricaneLamp.c 5KB
LCD1602.c 1KB
DS1302.c 549B
FlashLED.c 406B
Max7221.c 194B
Thumbs.db 5KB
Thumbs.db 5KB
Last Loaded HurricaneLamp.DBK 162KB
Last Loaded LiWan.DBK 157KB
Last Loaded FlashLED.DBK 126KB
Last Loaded LCD1602.DBK 104KB
Last Loaded DS1302.DBK 93KB
Last Loaded Max7221.DBK 92KB
Last Loaded PlayMusic.DBK 75KB
Backup Of Max7221.DBK 73KB
Backup Of DS1302.DBK 69KB
DS1302 16KB
HurricaneLamp.DSN 162KB
LiWan.DSN 157KB
FlashLED.DSN 127KB
LCD1602.DSN 104KB
DS1302.DSN 93KB
Max7221.DSN 92KB
PlayMusic.DSN 75KB
MusicEncode.exe 220KB
MusicEncode.exe 220KB
FlashLED 3KB
SoundPlay.h 6KB
DS1302.h 6KB
SoundPlay.h 5KB
LCD1602.h 4KB
LCD1602.h 4KB
Max7221.h 2KB
LiWan.hex 10KB
PlayMusic.hex 6KB
HurricaneLamp.hex 4KB
DS1302.hex 3KB
LCD1602.hex 2KB
Max7221.hex 1KB
FlashLED.hex 330B
HurricaneLamp 12KB
LCD1602 9KB
LiWan 23KB
HurricaneLamp.lnp 58B
PlayMusic.lnp 50B
FlashLED.lnp 48B
LCD1602.lnp 46B
Max7221.lnp 46B
DS1302.lnp 44B
LiWan.lnp 42B
LiWan.LST 25KB
HurricaneLamp.LST 13KB
STARTUP.LST 11KB
PlayMusic.LST 11KB
LCD1602.LST 3KB
DS1302.LST 2KB
FlashLED.LST 2KB
Max7221.LST 1KB
LiWan.M51 32KB
HurricaneLamp.M51 21KB
DS1302.M51 17KB
PlayMusic.M51 12KB
LCD1602.M51 10KB
Max7221.M51 5KB
FlashLED.M51 3KB
Max7221 5KB
LiWan.OBJ 28KB
DS1302.OBJ 19KB
HurricaneLamp.OBJ 15KB
PlayMusic.OBJ 12KB
LCD1602.OBJ 11KB
Max7221.OBJ 5KB
FlashLED.OBJ 3KB
STARTUP.OBJ 749B
共 129 条
- 1
- 2
资源评论
hdj126
- 粉丝: 0
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功