THe Code
link: https://makecode.com/_EUjTozPtoAD2
The logic of the speaker card is the same as the motor card. The only difference is that Circuit Playground already has a speaker block created for you, so you can utilize that. The pin A0 is specialized for speakers and is connected to the speaker on the board: all the sound blocks will trigger the A0 pin. Instead of digital writing high, you can simply bring in the play sound block to complete the actuation.
There is also a built-in speaker on the CPX. You would need to physically shut it off to disable this speaker so that you can hear your own speaker. To do this, you simply need to tape the special pin on the back of the CPX to Ground, using conductive tape. See images below.
On the right, conductive tape has been used to connect the speaker pin to Ground. Make sure that the copper (or conductive fabric) tape is not covering any other areas than the third circle on the right and the ground pin.

