资源简介
本设计是基于stc89c52单片机的节拍音乐器设计,部分代码参考网上实例,整体设计为个人原创,实测按键部分代码有些问题,尚未修改,不影响功能
代码片段和文件信息
#include
#include
#define uchar unsigned char
#define uint unsigned int
/*sbit wela = P2^6;
sbit dula = P2^7;*/
/*蜂鸣器定义*/
sbit beep1=P2^3; //左侧蜂鸣器
sbit beep2=P2^2; //右侧蜂鸣器
/*LCD端口定义*/
#define LCD_data P0 //数据口
sbit LCD_RS = P3^5; //寄存器选择输入
sbit LCD_RW = P3^6; //液晶读/写控制
sbit LCD_EN = P3^4; //液晶使能控制
sbit LCD_PSB = P3^7; //串/并方式控制
/*按键定义*/
sbit s1=P1^4; //模式选择按键,左1
sbit s2=P1^5; //增加键 + 左2
sbit s3=P1^6; //减少键 - 右2
sbit s4=P1^7; //确定按键,右1
uchar is1nums2nums3nums4numCount;
uchar tzhouqi = 7ge = 0shi = 6bai = 1;
uint bpm = 160fendu=2;
uchar code dis1[] = {“节拍器“};
uchar code dis2[] = {“节拍器“};
uchar code dis3[] = {“音乐盒“};
uchar code dis4[] = {“速度:“};
uchar code dis5[] = {“音量:“};
uchar code dis6[] = {“歌曲:祝你平安“};
uchar code SONG[] ={ //祝你平安
0x260x200x200x200x200x200x260x100x200x100x200x800x260x200x300x20
0x300x200x390x100x300x100x300x800x260x200x200x200x200x200x1c0x20
0x200x800x2b0x200x260x200x200x200x2b0x100x260x100x2b0x800x260x20
0x300x200x300x200x390x100x260x100x260x600x400x100x390x100x260x20
0x300x200x300x200x390x100x260x100x260x800x260x200x2b0x100x2b0x10
0x2b0x200x300x100x390x100x260x100x2b0x100x2b0x200x2b0x400x400x20
0x200x100x200x100x2b0x100x260x300x300x800x180x200x180x200x260x20
0x200x200x200x400x260x200x2b0x200x300x200x300x200x1c0x200x200x20
0x200x800x1c0x200x1c0x200x1c0x200x300x200x300x600x390x100x300x10
0x200x200x2b0x100x260x100x2b0x100x260x100x260x100x2b0x100x2b0x80
0x180x200x180x200x260x200x200x200x200x600x260x100x2b0x200x300x20
0x300x200x1c0x200x200x200x200x800x260x200x300x100x300x100x300x20
0x390x200x260x100x2b0x100x2b0x200x2b0x400x400x100x400x100x200x10
0x200x100x2b0x100x260x300x300x800x00
};
#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();};
uchar IRDIS[2];
uchar IRCOM[4];
void delay0(uchar x); //x*0.14MS
void dataconv();
void lcd_pos(uchar Xuchar Y); //确定lcd显示位置
/*******************************************************************/
/* */
/* 延时函数 */
/* */
/*******************************************************************/
void delay(int ms)
{
while(ms--)
{
uchar i;
for(i=0;i<250;i++)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}
/*-------------------------------------------------
功能:1MS延时函数
-------------------------------------------------*/
void Delay_xMs(unsigned int x)
{
unsigned int ij;
for( i
相关资源
- 基于51单片机AD7705使用的C程序
- 两片74HC595显示4位数码程序(C51单片机
- 基于C51单片机多功能时钟系统
- 基于51单片机的10位DA芯片 TLC5615的C应
- 嵌入式系统图形界面 GUI 基于51单片机
- 51单片机控制智能恒温混水阀
- 51单片机红外收发程序
- 51单片机作为i2c从设备加密芯片+红外
- STC89C51单片机RC522读卡程序,Keil文件,
- 电子称 51单片机 1602显示 HX710AD芯片
- 51单片机驱动160160液晶显示程序
- L298控制直流电机加减速的89c51单片机
- 蜂鸣器播放音乐-小星星亮晶晶.rar
- 51单片机 RTL8019AS 网卡驱动程序(有
- 源程序 - 副本.rar
- 基于单片机的交通灯控制系统设计程
- 基于51单片机的电子表
- 基于51单片机实现简单五子棋
- 数字温度计用51单片机程序
- 51单片机利用8266wifi获取网络时间,亲
- 51单片机频率计程序
- 基于51单片机和热敏电阻数字温度计
- 单片机数码管显示温度
- 基于51单片机的只能台灯
- 51单片机 LCD12864程序显示文字或者图片
- 51单片机mpu6050读取六轴原始数据并L
- DS2782 美信电量计芯片 IIC STM32/STM8/5
- 基于C51单片机的8×8-LED点阵屏汉字显示
- 音乐频谱显示参考源代码.rar
- 红外温度测温成功mxl90614
评论
共有 条评论