3.4 Power Amplifier

3.4.1 Overview

The 8002b power amplifier mainly consists of a speaker and an audio amplification chip. It can amplify small audio signals for about 8.5 times. These amplified sounds will be played through its speaker. Besides, it can also play some music or melodies.

3.4.2 Schematic Diagram

6-4

3.4.3 Code Blocks

  1. j17

    This block sets tones and durations to emit a certain sound of tone.

  2. image

    This block integrates some songs so that you can directly use.

  3. j19

    This block stops the play of tones.

3.4.4 Test Code

3.4.4.1 Build Code

There are two ways to upload the code: directly open the code file we provide; or manually build blocks.

Directly open the code file we provide:

  1. Click and choose Load from your computer

  1. We have already downloaded the codes on computer desktop, so open the file and choose 3-4-speaker.sb3

Manually build blocks:

  1. In events, find j1 block.

  2. In control, find and place j2 block under j1.

6-1-4-1-1

  1. In spk, set frequency to NOTE_C4 and duration to 500 in blockj17.

  2. Similarly, add NOTE_D4, NOTE_E4, NOTE_F4, NOTE_G4, NOTE_A4, NOTE_B4

  3. At last add a j19.

Complete Test Code

6-4

3.4.4.2 Test Result

After uploading code, the power amplifier plays Do, Re, Mi, Fa, So, La, Si, in a loop.

3.4.5 Extension

We make the module to play music.

3.4.5.1 Test Code

There are two ways to upload the code: directly open the code file we provide; or manually build blocks.

Directly open the code file we provide:

  1. Click and choose Load from your computer

  1. We have already downloaded the codes on computer desktop, so open the file and choose 3-4-speaker2.sb3

Manually build blocks:

6-4

3.4.5.2 Test Result

After uploading code, the amplifier plays Birthday Song.