Experiment 2 speaker experiment

1、 Experimental purpose

1. Master the hardware circuit of loudspeaker;

2. Master the programming of speakers and how to make speakers make different sounds.

2、 Experimental description

LM386 pin description is shown in Figure 2-1 LM386 pin introduction

Experimental design of single chip microcomputer loudspeaker

LM386 is an audio integrated power amplifier. It has the advantages of low power consumption, adjustable voltage gain, large power supply voltage range, few external components and low total harmonic distortion. It is widely used in tape recorders and radios.

Pin 2 is the inverting input and 3 is the in-phase input; Pin 5 is the output; Pins 6 and 4 are power and ground respectively; Pins 1 and 8 are voltage gain setting terminals; When in use, between pin 7 and ground

Bypass capacitance is connected between them, usually 10 μ F。

Figure 2-1 LM386 pin introduction

In this experiment, the speaker is controlled by single chip microcomputer to produce seven notes. The PCA / PWM clock output mode of single chip microcomputer STC12C5A60S2 outputs high-speed pulse. After amplification and filtering, the pulse drives the speaker to make sound. The frequency of the sound is determined by the timing constant, and the length of the sound is controlled by the timer T0. The experiment only gives 7 audio programs.

3、 Experiment contents and steps


The p1.3 port of the smallest system unit of the single chip microcomputer sends out high-speed pulse, and the signal line is used to connect the p1.3 port with the VIN port of the voice system unit. The program function makes the speaker circulate seven notes, and the adjustable resistance is used to adjust the size of the sound.


1. According to the hardware connection circuit, program and compile to generate *. Hex file;

2. Turn on the power supply of the test box;

3. Refer to STC in STC12C5A60S2 download instructions_ ISP software instructions, download the program to the MCU;

4. Connect p1.3 of the smallest system unit of single chip microcomputer with VIN port of voice system unit with signal line;

5. Turn on the voice system unit switch;

6. When you hear the speaker, it will cycle seven notes, and use the adjustable resistor to adjust the loudness of the sound. If the result is incorrect, please modify the program and repeat the above operation.

Leave a Reply

Your email address will not be published. Required fields are marked *