Wheel IDE

Online demo »

Sound, tone

Sound tone example

This example shows how to play tones.

Code

#project "Sound tone example"

#include "lib/modules/standard.whl"
#include "lib/modules/device.whl"
#include "lib/modules/sound.whl"

#display "EV3"

proc main()
    ; Select the EV3 device in the simulator...
    selectDevice(DEVICE_EV3)

    number tones[10] = [TONE_C4, TONE_D4, TONE_E4, TONE_F4, TONE_G4, TONE_A4, TONE_B4, TONE_C5, TONE_D5, TONE_E5]
    number n

    for n = 0 to 9
        ; Play the tone with the given frequency, duration and volume...
        playTone(tones[n], 50, 30)
    end
end
See also: Modules playTone