资源简介

里面包括两个文档,一个是C语言写的程序,另外一个是可以直接烧进单片机进行执行的hex文件,该程序主要功能是通过两个按键,来选择两首旋律,分别是《两只老虎》和《蝶恋》

资源截图

代码片段和文件信息

//用定时器产生延迟,并通过蜂鸣器来播放一段旋律,下表为各个音符对应的频率值
//---------------------------------------------------------------------------------------------------------------------------------------------
//简谱                  1        2       3        4        5          6         7          1          2        3         4        5         6       7        1 
//频率                  523      587     659      698      784        880       987        1046       1174     1318      1396     1567      1760    1975    2092  
//周期(us)             1912.04 1703.58  1517.45  1432.7   1275.5     1136.4    1013.2     956        851.8    758.7     716.3    638.2     568.2   506.3   478 
//半周期                956     851.8    758.73   716.3    637.7      568.2     506.6      478        425.9    379.3     358.1    319.1     284.1   253.1   239 
//本程序对应的数字      0xEF    0xD5     0xCE     0xb3     0xa0       0x8e      0x7f       0x78       0x6A     0x5f      0x5a     0x50      0x47    0x3f    0x3c
//----------------------------------------------------------------------------------------
//
#include
#define uint unsigned int
#define uchar unsigned char
#define ulong unsigned long

sbit BEEP=P3^7;      //喇叭输出端
sbit LED=P0^5;       //指示灯端口
uchar  Song_index;

uchar status;      //用于判断按键是否按下

uchar code song[]={0x780x100x6A0x100x5F0x100x780x100x780x100x6A0x100x5F0x100x780x100x5F0x100x5A0x100x500x200x5F0x100x5A0x100x500x20
                   0x500x080x470x080x500x080x5A0x050x5F0x100x780x100x500x080x470x080x500x080x5A0x080x5F0x100x780x10
   0x780x100xA00x100x780x200x780x100xA00x100x780x200x00//两只老虎
   0x5F0x100x5F0x100x5F0x100x6A0x100x5F0x40
                   0x6A0x100x5F0x100x6A0x100x6A0x100x8E0x200x8E0x100x7F0x100x780x200x6A0x10
                   0x780x100x7F0x200x8E0x100xA00x100x8E0x80/*一起走过*/
   0x5F0x100x5F0x100x5F0x100x6A0x100x5F0x300x470x100x500x100x470x100x500x100x500x100x6A0x20
   0x6A0x100x5F0x100x5A0x200x500x100x5A0x100x5F0x200x6A0x100x780x100x5F0x70/*的承诺*/
   0x5F0x100x470x200x3F0x100x470x100x500x300x5F0x100x500x60/*飘过*/
                   0x5F0x100x500x100x6A0x200x470x100x500x100x5F0x200x6A0x100x6A0x100x5F0x80/*传说*/
                   0x6A0x200x470x100x470x500x780x200x470x100x470x300x470x100x3F0x100x3C0x20/*天地痴*/
   0x3F0x100x470x100x3F0x200x500x200x470x800x000x00};
/*uchar code song2[]={0x5F0x100x5F0x100x5F0x100x6A0x100x5F0x40
                    0x6A0x100x5F0x100x6A0x100x6A0x100x8E0x200x8E0x100x7F0x100x780x200x6A0x10
                   0x780x100x7F0x200x8E0x100xA00x100x8E0x80//一起走过
   0x5F0x100x5F0x100x5F0x100x6A0x100x5F0x300x470x100x500x100x470x100x500x100x500x100x6A0x20
   0x6A0x100x5F0x100x5A0x200x500x100x5A0x100x5F0x200x6A0x1

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       5467  2009-10-17 19:56  Music_Rhythm.c

     文件       1313  2009-10-17 19:01  Music_Rhythm.hex

----------- ---------  ---------- -----  ----

                 6780                    2


评论

共有 条评论