1. Hardware Solution
This design uses the 51 single-chip microcomputer principle and control theory to design the hardware circuit of the music performance controller, and uses C language for program design. By controlling the timer inside the single-chip microcomputer to generate square waves of different frequencies, the buzzer is driven to emit music of different tones, and the delay is used to control the length of the pronunciation time. By converting the music score into the corresponding timing constant, you can play pleasant music from the pronunciation device.
It is mainly composed of 51 single chip microcomputer + minimum system + LM386 power amplifier circuit + speaker + LED indicator module + button module; as shown in the figure:
2. Design function
(1) Using an external power amplifier circuit and LM386 chip to drive the speaker, the hardware circuit of the music player is formed;
(2) Built-in 8 songs;
(3) Four button functions: a single button for reset, previous song, start/pause, and next song;
3. Design Schematic
(1) The schematic diagram is mainly designed using AD software, as shown in the figure:
(2) The Protues simulation diagram is as follows:
(3) The PCB diagram is as follows:
4. Software Design
(1) Program flow chart
(2) Main program source code
void main(void)
{
TMOD=0x11; //T0 T1 are both in working mode 1
ET0=1; //T0 opens interrupt
EA=1; //CPU interrupt
while(1)
{
music_play(); //Play a note of the corresponding song according to the current state
if(!pause) //Pause key processing
{
delayms(5);
if(!pause)
{
if(music_num==0) //music_num=0 only exists when the device is just powered on and the pause button is not pressed, indicating the state when the device is just powered on. Press the button to start playing from the first song.
{
music_num=1; //Set the song number to 1
num=0; //play from the beginning
play_enable=1; //Allow playback
}
else
{
play_enable=~play_enable;
speaker=1;
}
while(!pause) //What to do if you hold down the pause button
{
if(play_enable==0){} //If it is paused, the display time remains unchanged //(play_enable==0 when paused)
}
}//Pause key processing ends
}//while ends
if((!play_up)&&(music_num!=0)) //Previous song button
{
delayms(5);
if((!play_up)&&(music_num!=0))
{ speaker=1;
music_num-=1; // song number minus one
if(music_num<=0)
music_num=8;
num=0; //Start playing from the beginning
if(music_num==(sound_amount+1))
music_num=1;
delayms(500); // song switching delay 0.5S
}
}
if((!play_down)&&(music_num!=0))
{
delayms(5);
if((!play_down)&&(music_num!=0))
{ speaker=1;
music_num+=1; //Song number plus one
if(music_num>=9)
music_num=1;
num=0; //Start playing from the beginning
if(music_num==0)
music_num=sound_amount;
delayms(500); // song switching delay 0.5S
}
}
}
}
Previous article:Automobile Intelligent Lighting Control System Based on 51 Single Chip Microcomputer
Next article:Wireless anti-theft alarm based on 51 single chip microcomputer
- Popular Resources
- Popular amplifiers
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
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Looking for a chip that can increase 12V to 12.6V/3A
- 【NUCLEO-F746ZG Motor】Based on SDK5.4.5-Project Build
- HDL Language Quick Guide
- How to select external clock for TMS320 series
- (Bonus 10) GD32L233 Review - SPI Driver DS1302
- O-RAN Testing Tool - Terminal Emulator UEE, Do You Know It?
- [Evaluation of domestic FPGA Gaoyun GW1N-4 series development board]——5. Internal Flash and external Flash program curing test
- Without exaggeration or criticism, SS5 is the smoothest and most user-friendly Eclipse-based IDE I have ever used.
- [2022 Digi-Key Innovation Design Competition] 4. ESP32-S2-Kaluga-1 running LVGL
- TMS320-F2818 DC resistance comparator