Ameba Arduino: [RTL8722CSM] [RTL8722DM] PWM – Play Music
- Ameba x 1
- Buzzer x 1
In this example, we use PWM to control the buzzer to emit sound with desired tone. As PWM outputs square wave, if we wish to emit tone C4 (frequency=262Hz), we have to make PWM to output square wave with wavelength 1/262 = 3.8ms:
We use PWM to output sound wave with different frequency, so as to play music by the buzzer.
Connect the buzzer to the PWM output pin shown in the following diagrams.
RTL8722 wiring diagram:
Open the example code in “Examples” -> “AmebaAnalog” -> “TonePlayMelody”
Compile and upload to Ameba, press the reset button. Then you can hear the buzzer playing music.