• 大小: 17KB
    文件类型: .c
    金币: 1
    下载: 0 次
    发布日期: 2021-06-29
  • 语言: 其他
  • 标签: 51单片机  

资源简介

本设计是基于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

评论

共有 条评论