SunFounder ESP32 Starter Kit
3. Press the button and the bell makes a sound
Use [if then] to make a conditional statement that when the value of the pin14 read is equal to 1 (the key is pressed),
the sound xylo1 will be played.
• [read status of digital pin]: This block is from the ESP32 palette and used to read the value of a digital pin, the
result is 0 or 1.
• [if then]: This block is a control block and from Control palette. If its boolean condition is true, the blocks held
inside it will run, and then the script involved will continue. If the condition is false, the scripts inside the block
will be ignored. The condition is only checked once; if the condition turns to false while the script inside the
block is running, it will keep running until it has finished.
• [play sound until done]: This block is from the Sound palette, used to play specific sounds.
504 Chapter 4. Play with Scratch