Sound Effect

PiCar-X has a built-in speaker that can be used for audio experiments. Ezblock allows users to enter text to make the PiCar-X speak, or make specific sound effects. In this tutorial, the PiCar-X will make the sound of a gun firing after a 3-second countdown, using a do/while function.

TIPS

../_images/sp210512_144106.png

Use the say block with a text block to write a sentence for the PiCar-X to say. The say block can be used with text or numbers.

../_images/sp210512_144150.png

The number block.

../_images/sp210512_144216.png

Using the repeat block will repeatedly execute the same statement, which reduces the size of the code.

../_images/sp210512_144418.png

The mathematical operation block can perform typical mathematical functions, such as ”+”, “-”, “x”, and “÷ “.

../_images/sp210512_144530.png

The play sound effects - with volume - % block has preset sound effects, such as a siren sound, a gun sound, and others. The range of the volume can be set from 0 to 100.

EXAMPLE

Note

  • You can write the program according to the following picture, please refer to the tutorial: How to Create a New Project?.

  • Or find the code with the same name on the Examples page of the EzBlock Studio and click Run or Edit directly.

../_images/sp210512_144944.png