-
Notifications
You must be signed in to change notification settings - Fork 2
demarrer avec un son
Victoria Vila edited this page Sep 10, 2018
·
9 revisions
Écrivez un programme qui fasse démarrer le robot quand vous frappez dans vos mains et le fasse s’arrêter lorsque vous touchez un bouton
# setup threshold for detecting claps
mic.threshold = 250
# 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)
onevent buttons
when button.center == 1 do
motor.left.target = 0
motor.right.target = 0
emit pair_run 1
end
onevent mic
motor.left.target = 350
motor.right.target = 400
emit pair_run 0
Écrivez un programme qui fasse l’opposé : le robot démarre lorsque vous touchez un bouton et s’arrête lorsque vous frappez dans vos mains.
Le problème de ce programme est que le Thymio fait du bruit lorsqu'il démarre. Il s'éteint donc directement. La solution est de faire avancer le Thymio a une vitesse lente, ainsi le bruit des moteurs n'est pas détecter.
empty
# setup threshold for detecting claps
mic.threshold = 250
# 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)
onevent buttons
when button.center == 1 do
motor.left.target = 150
motor.right.target = 150
emit pair_run 0
end
onevent mic
motor.left.target = 0
motor.right.target = 0
emit pair_run 1