Thymio as musical instrument
By connecting the front distance sensors and the sound, one can make a little musical instrument like this:
There can be five notes, or more if one uses the rear or lateral sensors or the tilt of the robot to choose a range of notes. The major limitation comes from the fact that only 10 sounds can be stored on the SD card.
This is a video of what that gives:
The code used in the video is as follows:
onevent prox
if acc[1]>0 then
if prox.horizontal[0]>4000 then
call sound.play(1)
call leds.top(32, 32, 32)
end
if prox.horizontal[1]>4000 then
call sound.play(2)
call leds.top(32, 0, 0)
end
if prox.horizontal[2]>4000 then
call sound.play(3)
call leds.top(0, 32, 0)
end
if prox.horizontal[3]>4000 then
call sound.play(4)
call leds.top(0, 0, 32)
end
else
if prox.horizontal[0]>4000 then
call sound.play(6)
call leds.top(32, 32, 32)
end
if prox.horizontal[1]>4000 then
call sound.play(7)
call leds.top(32, 0, 0)
end
if prox.horizontal[2]>4000 then
call sound.play(8)
call leds.top(0, 32, 0)
end
if prox.horizontal[3]>4000 then
call sound.play(9)
call leds.top(0, 0, 32)
end
end
In order for this to work an SD card is needed containing the sound files. You can download the files here.
This idea can be developed or used in different ways:
- How to make it more interactive? (colours, other sounds, interaction)
- How to optimise the code? (a loop instead of the list of if)
- Construct an instrument around the Thymio II? With several Thymio II?
- How is a sound made? What is the effect of having a sound sampled at 8kHz instead of the 44.1 kHz of CD quality?