TD 12 M&R

Oh tomate, Yann Chevaleyre (licence wtfpl)
, par
Dernier TP, libre avec quelques indications.
- import pythymio as pt
- import time
- custom = pt.customEvents('colors', 'sound')
- state = {}
- state["i"] = 100
- state["j"] = 100
- with pt.thymio(['buttons', 'prox'], custom) as Thym:
- def progression(id,evt,data):
- if evt == "fwd.buttons":
- if data[0] == 1:
- Thym.set('motor.left.target', 500)
- Thym.set('motor.right.target', 500)
- Thym.send_event('become.blue')
- else:
- Thym.set('motor.left.target', 0)
- Thym.set('motor.right.target', 0)
- Thym.send_event('become.green')
- state["i"] -= 1
- if state["i"] == 0:
- print('le tableau de boutons est ',list(data))
- state["i"] = 100
- if evt == "fwd.prox":
- state["j"] -= 1
- if state["j"] == 0:
- print('le tableau des telemetres est ',list(data))
- state["j"] = 100
Documents joints
- tp_dfa.pdf (PDF – 245.3 ko)