#include #define uchar unsigned char #define uint unsigned int sbit BEEP=P3^7; //Happy Birthday song note frequency table, different frequencies are determined by different delays uchar code SONG_TONE[]= {212,212,190,212,159,169,212,212,190,212,142,159,212,212,106,126,159,169,190,119,119,126,159,142,159,0}; //Happy Birthday song beat chart, the beat determines the playing length of each note uchar code SONG_LONG[]= {9,3,12,12,12,24,9,3,12,12,12,24, 9,3,12,12,12,12,12,9,3,12,12,12,24,0}; //Delay void DelayMS(uint x) { flying t; while(x--) for(t=0;t<120;t++); } //Play function void PlayMusic() { uint i=0,j,k; while(SONG_LONG[i]!=0||SONG_TONE[i]!=0) { //Play each note, SONG_LONG is the beat length for(j=0;j BEEP=~BEEP; //SONG_TONE delay table determines the frequency of each note for(k=0;k DelayMS(10); i++; } } void main() { BEEP=0; while(1) { PlayMusic(); //Play Happy Birthday DelayMS(500); //Pause for a while after playing } }
Previous article:Microcontroller - Buzzer (Happy Birthday)
Next article:51 single chip microcomputer realizes the birthday song
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Why software-defined vehicles transform cars from tools into living spaces
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- How to send two-way PWM with dead zone complementation in micropython
- TMS320F28335 Serial Port SCI
- Multi-channel current detection
- 【Topmicro Intelligent Display Module】Part 4: Comprehensive evaluation of text scrolling, RTC, etc.
- Display QR code-Intelligent TFT module
- EEWORLD University ---- Open Source PWM Robotic Arm (STM32 Version) Video Tutorial
- [RVB2601 Creative Application Development] Part 4 Sound Histogram
- Waveform changes of different ANT frequencies
- Regulator tube usage help
- [GD32L233C-START Review] IV. USART