Projet Maternelle A Camus Talence Thymio / Musique

Camusmat042015 un double projet

Les élèves seront amenés à créer un environnement dans lequel Thymio pourra évoluer en autonomie . Les données reccueillies par tous ses capteurs seront utilisées pour être intégrées au logiciel I Score et générer des sons.

1 « J'aime »

Thymio peut à présent éviter les obstacles en jouant un son stocké sur la Carte SD ,
Chaque capteur de présence déclenche un son. Attention les son doivent être au format .wav mono 8bits 8000Hz voir https://www.thymio.org/fr:thymioapi-oldv3v6 section création de son.
C’est peut être pas très orthodoxe comme script
J’ai utilisé le VPL dans Aseba Studio pour faire le code des déplacement et ensuite
avec quelques essais et aménagements j’y ai ajouté le code trouvé sur cette page Thymio Musique https://www.thymio.org/en:thymiomusic.
Bricolage j’adore ; si quelqu’un veut mettre de l’ordre et de la méthode dans tout cela , c’est aussi bienvenu!!

variables for state

var state[4] = [0,0,0,0]
var new_state[4] = [0,0,0,0]

reset outputs

call sound.system(-1)
call leds.top(0,0,0)
call leds.bottom.left(0,0,0)
call leds.bottom.right(0,0,0)
call leds.circle(0,0,0,0,0,0,0,0)

subroutine to display the current state

sub display_state
call leds.circle(0,state[1]*32,0,state[3]*32,0,state[2]*32,0,state[0]*32)

onevent prox
when prox.horizontal[0] < 1600 and prox.horizontal[1] < 1600 and prox.horizontal[2] < 1600 and prox.horizontal[3] < 1600 and prox.horizontal[4] < 1600 do
motor.left.target = 300
motor.right.target = 300
call leds.bottom.left(30,30,0)
call leds.bottom.right(30,30,0)
end
when prox.horizontal[0] > 1400 do
motor.left.target = -200
motor.right.target = -500
call leds.top(10,32,0)
end

when prox.horizontal[1] > 1600 do
	motor.left.target = 500
	motor.right.target = -500
	call leds.top(30,0,0)
end

when prox.horizontal[2] > 2000 do
	motor.left.target = -500
	motor.right.target = -500
	call leds.top(0,0,32)
end

when prox.horizontal[3] > 2000 do
	motor.left.target = -500
	motor.right.target = 500
	call leds.top(29,0,26)
end

when prox.horizontal[4] > 2000 do
	motor.left.target = -500
	motor.right.target = -200
	call leds.bottom.left(13,22,0)
	call leds.bottom.right(13,22,0)
end

when prox.horizontal[0] > 2000 and prox.horizontal[4] > 2000 do
	motor.left.target = -500
	motor.right.target = -300
end
when prox.horizontal[5] > 2000 do
	motor.left.target = 350
	motor.right.target = 0
end
when prox.horizontal[6] > 2000 do
	motor.left.target = 0
	motor.right.target = 350
end


call math.copy(state, new_state)
callsub display_state

#son1
if acc[1]>0 then
if prox.horizontal[0]>4000 then
call sound.play(1)
end
#son2
if prox.horizontal[1]>4000 then
call sound.play(2)
end
#son3
if prox.horizontal[2]>4000 then
call sound.play(3)
end
#son4
if prox.horizontal[3]>4000 then
call sound.play(4)
end
#son5
if prox.horizontal[4]>4000 then
call sound.play(5)
end
#son6
if prox.horizontal[5]>4000 then
call sound.play(6)
end
#son7
if prox.horizontal[6]>4000 then
call sound.play(7)
end
end