Sound waves are vibrations in the air pressure. The speed of the vibrations (cycles per second or Hertz) is what makes the pitch of the sound. The higher the frequency of the vibration, the higher the pitch.
Middle C is usually defined as a frequency of 261 Hz. If you turn a digital output on and off again 261 times every second then that output will be middle C.
To hear the output, we need to attach something that will convert the electrical signal into sound waves. This can be done with a loudspeaker or as we have used here a piezo sounder.
Piezo sounders use a special crystal that expands and contracts as an electrical signal passes through it. This will generate a tone that we can hear.