Sound
PLAY
It is possible to play sounds. In the Setup/Peripheral menu, you must configure the speaker or piezo. In Open-Drain mode, the speaker should be connected between the pin and 3.3 V, or 5 V for higher volume. LOW/HIGH represents the inactive state.
PLAY(RTTTL)#mario.txt
This command plays
Ring Tone Text Transfer Language
(RTTTL) files developed by Nokia from storage. The installer includes ~12,000 ready-made files in the peripherals/SOUND/RTTTL folder.
PLAY(WAV)#pcm0808m.wav
This command plays .wav files from storage. Works only on the RX pin!!! It is not included in the Lite version!!! This is a hardware limitation.
It is recommended to use mono 8-bit 8kHz format. A converter program is included in the installer under peripherals/SOUND/WAV/sox.
Usage: sox input.mp3 -r 8000 -c 1 -b 8 output.wav
PLAY!
Stops playback.
PLAY:LED(FLASH)
When the music ends, this command is executed (LED flashes).
BEEP
BEEP(432)
Generates a sound at 432Hz frequency.
BEEP!
Stops the beep.
NUM[0]=1000|
NUM[1]=2000
BEEP(NUM[0],NUM[1])
Generates a 1kHz beep for two seconds.
Examples
BEEP something
TIMER[0]CS:*BEEP(500)|
TIMER[0]CE1:*BEEP(1000)|
TIMER[0]CF:BEEP!|
TIMER[0](100,30x)
Pressing a button plays sound0.txt - sound4.txt.
GPIO[D5]INP|
GPIO[D5]CL:NUM[0]+1|
NUM[0]VL=0|
NUM[0]VH=5|
NUM[0]CH:NUM[0]=VL|
NUM[0]CC:STR[1]=sound;STR[1]>NUM[0];STR[1]>.txt;PLAY(RTTTL)#STR[1]|
PLAY:STD@END