C51 single chip buzzer two butterfly code

Publisher:缘到泉Latest update time:2017-11-11 Source: eefocusKeywords:C51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

#include // This is the code generated by the MCU music code generator

#define uchar unsigned char

sbit beepIO=P1^5; // Output is P1.5, can be changed to other IO ports

flying m,n; 

uchar code T[49][2]={{0,0},

{0xF8,0x8B},{0xF8,0xF2},{0xF9,0x5B},{0xF9,0xB7},{0xFA,0x14},{0xFA,0x66},{0xFA,0xB9},{0xFB,0x03},{0xFB,0x4A},{0xFB,0x8F},{0xFB,0xCF},{0xFC,0x0B},

{0xFC,0x43},{0xFC,0x78},{0xFC,0xAB},{0xFC,0xDB},{0xFD,0x08},{0xFD,0x33},{0xFD,0x5B},{0xFD,0x81},{0xFD,0xA5},{0xFD,0xC7},{0xFD,0xE7},{0xFE,0x05},

{0xFE,0x21},{0xFE,0x3C},{0xFE,0x55},{0xFE,0x6D},{0xFE,0x84},{0xFE,0x99},{0xFE,0xAD},{0xFE,0xC0},{0xFE,0x02},{0xFE,0xE3},{0xFE,0xF3},{0xFF,0x02},

{0xFF,0x10},{0xFF,0x1D},{0xFF,0x2A},{0xFF,0x36},{0xFF,0x42},{0xFF,0x4C},{0xFF,0x56},{0xFF,0x60},{0xFF,0x69},{0xFF,0x71},{0xFF,0x79},{0xFF,0x81}

};

uchar code music[][2]={{0,4},

{23,4},{21,4},{23,16},{23,4},{21,4},{23,4},{21,4},{19,16},{16,4},{19,4},{21,8},{21,4},{23,4},{21,4},{19,4},{16,4},{19,4},{14,24},

{23,4},{21,4},{23,16},{23,4},{21,4},{23,4},{21,4},{19,24},{16,4},{19,4},{21,8},{21,4},{23,4},{21,4},{19,4},{16,4},{19,4},{21,24},

{23,4},{21,4},{23,16},{23,4},{21,4},{23,4},{21,4},{19,16},{16,4},{19,4},{21,8},{21,4},{23,4},{21,4},{19,4},{16,4},{19,4},{14,24},

{23,4},{26,4},{26,16},{26,4},{28,4},{26,4},{23,24},{21,4},{23,4},{21,8},{21,4},{23,4},{21,4},{19,4},{16,4},{16,2},{19,2},{19,24},{0,20},

{26,4},{26,4},{28,4},{31,4},{30,4},{30,4},{28,4},{23,4},{21,4},{21,4},{23,16},{0,4},{23,4},{23,4},{26,4},{28,8},{28,12},{16,4},{23,4},{21,4},

{21,24},{23,4},{26,4},{26,4},{23,4},{26,8},{0,4},{31,8},{30,4},{28,4},{30,4},{23,8},{0,4},{28,4},{28,4},{30,4},{28,4},{26,4},{23,4},{21,8},{23,4},{21,4},{23,4},{26,16},

{0xFF,0xFF}};

void delay(float p)

{

    flying i,j; 

    for(;p>0;p--)

    for(i=181;i>0;i--)

    for(j=181;j>0;j--);

}

void pause()

{

    flying i,j;

    for(i=150;i>0;i--)

    for(j=150;j>0;j--);

}

void T0_int() interrupt 1

{

 beepIO=!beepIO;

 TH0=T[m][0]; TL0=T[m][1];

}

void main()

{

 fly i=0; 

 TMOD=0x01;  EA=1; ET0=1; 

 while(1) 

      {

        m=music[i][0];n=music[i][1]; 

           if(m==0x00)

             {TR0=0;delay(n);i++;} 

           else if(m==0xFF)

             {TR0=0;delay(30);i=0;} 

           else if(m==music[i+1][0]) 

             {TR0=1;delay(n);TR0=0;pause();i++;}

           else

             {TR0=1;delay(n);i++;}

      }


Keywords:C51 Reference address:C51 single chip buzzer two butterfly code

Previous article:C51 single chip buzzer wish you peace music
Next article:C51 Buzzer Happy Birthday Code

Recommended ReadingLatest update time:2024-11-16 14:43

C51 MCU Study Notes LED
Introduction LED is a light emitting diode, there is nothing much to say. The only point is that low level is effective! Schematic   Code section #include REGX52.H     void delay() { unsigned int i; for(i=0;i 30000;i++); } main() {   unsigned int i; unsigned char J;   while(1) { /*P0=0xFE; delay(
[Microcontroller]
C51 MCU Study Notes LED
C51---8 serial ports
Serial port introduction ✨ The serial port is a widely used communication interface. It is low-cost, easy to use, has simple communication lines, and can enable two devices to communicate with each other. The serial port of the microcontroller can connect the microcontroller to the microcontroller, the microcontroller
[Microcontroller]
C51---8 serial ports
Implementation of running water lamp in "Beginner's C51 Self-study Notes" (Shift Operation 2)
#include reg52.h #include intrins.h   #define uchar unsigned char  #define uint unsigned int void delay(void) { uchar a,b; for(a=0;a 200;a++) for(b=0;b 200;b++); }   void main() { uchar k; k=0xfe; //11111110 while(1) { P0=k; delay(); k=_crol_(k,1);//Shift K by one bit 11111101 11111011 11110111..
[Microcontroller]
51 single chip microcomputer program - timer control buzzer
#include #define uint unsigned int    sbit bb=P3^5;                   //bit definition buzzer interface sbit led1=P0^0;       //bit definition LED interface unsigned int i=0;   void delay(uint z);       //delay function declaration   void main() { TMOD=0x01;                 //TMOD assignment t
[Microcontroller]
Summary of C51 digital tube display related issues
1. Static display of a single digital tube /*-------------------------- Function: Static display of a digital tube Author: Zhang Kaizhou Date: 2019-5-16 21:18:17 --------------------------*/ #include reg52.h sbit duan_address = P2^6; // Define segment address as a bit addressable variable sbit wei_address = P2^7;
[Microcontroller]
A multi-tasking mechanism and application based on C51
Introduction   Traditional microcontroller programs generally use a single-task mechanism. Single-task systems have the advantages of being simple, intuitive, and easy to control. However, since the program can only be executed in sequence and lacks flexibility, interrupt functions can only be used to process some sh
[Microcontroller]
C51 Programming 20-Application (LCD1602 Display-1)
Looking back at the previous programming tutorials, the first one is the I/O chapter. I/O mainly explains the pin characteristics of I/O and how to control the level input and output of I/O through C51; the second one is the interrupt chapter. The interrupt chapter introduces the necessity of the interrupt system and
[Microcontroller]
C51 Programming 20-Application (LCD1602 Display-1)
Self-made PID program (C51, incremental PID)
void PID(void) {    //Difference VW88, voltage feedback VW50, pid operation feedback: VW10, pid given: VW700  int VW700, VW50; //0-32768~+32768  int VW500, VW502, VW504, VW506;  long VW530, VW538;  int VW526, VW522, VW524;      uchar Kp=7; //P value 0-20 book: 20 PLC test 3\1\7  uchar Ki=4; //I value 0-20 book: 01  uc
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号