Integrating the sound sensor
The sound sensor can be a useful tool in getting your program to interact with the outside environment.
Just like the other blocks we've used so far, the sound returns a value between 0 and 100. It is simply a measure of how loud the area around the sensor is, and it is not a microphone.
Getting ready
In this recipe we are going to explore the sound sensor by making the cat make a meow sound when a loud noise is detected by the sensor. To prepare for this, all you need to do is open a new Scratch file.
How to do it...
Here are the steps we'll need to get this going:
- Drag over a block.
Similar to the forever loop we've used before, we can also use the forever if loop. Drag it into the sequence.
Under the Operators category, drag over a () > () block into the conditional spot of the forever if loop. (Note that in Scratch 2.0 this loop doesn't exist, and we build it using the forever loop and if statement.) You should have this code now:
Within the first open spot...