Capture sound input
We're going to create a quick program that switches the background when a sound is made.
Time for action – switch backgrounds on sound
Let's emulate night and day with our backgrounds so that each sound changes the scene. Open a new Scratch project and begin:
Create the second background by copying the default white background. Then, edit background2 and use the fill tool to paint it black.
Add the when flag clicked control block to the scripts area of the stage.
Add a forever if block to the when flag clicked block.
We need to evaluate the sound level before we act on it. From the Operators palette, add the greater than block.
Now, let's evaluate the sound. From the Sensing palette, drag the sensor value block into the first field of the greater than block. Select the sound option from the drop-down list of options.
We want to switch the background whenever the sound is greater than 0. Type a 0 in the second field of the greater than block so that the statement reads sound sensor...