LES PROJETS
PROJET 1 - COMMENT REALISER UN COMPTEUR DE SALLE DE SPECTACLE ?
DEMARCHE DE PROJET : 
Problématique : 
Comment réaliser un compteur de personnes pour un spectacle ? 
 
Lire le diaporama ODT
Lire le diaporama PDF



 Dans cette période de COVID la jauge de la salle est de 120 personnes afin de permettre la distanciation entre les sièges

-----------------------------------------------------------

PROGRAMME 1 : 

EXERCICE 1.mp4 
 
tp1.mp4 
 
Programme PYTHON : 

Programme py

Programme hex
 
from microbit import * 
 
nb_spectateurs = 0 
 
# Répéter indéfiniement 
while True: 
if button_a.was_pressed(): 
nb_spectateurs = nb_spectateurs+1 
display.show(nb_spectateurs) 

 
----------------------------------------------------------- 
 
PROGRAMME DANS CREATE WITH CODE : 
 
PROGRAMME 1 DANS CREATE WITH CODE

ATTENTION RAJOUTER LE STRING DANS display.show(str(nb_spectateurs)) dans https://create.withcode.uk/

-----------------------------------------------------------

PROGRAMME 2 :
LE BOUTON B REMET LE COMPTEUR A ZERO 
 
EXERCICE 2.mp4 
 
tp2.mp4 
 
------------------------------------------------------------ 
 
Programme PYTHON : 

Programme py

Programme hex
 
from microbit import * 
 
nb_spectateurs = 0 
 
# Répéter indéfiniement 
while True: 
if button_a.was_pressed(): 
nb_spectateurs = nb_spectateurs+1 
display.show(nb_spectateurs) 
if button_b.was_pressed(): 
nb_spectateurs = 0 

 
------------------------------------------------------------
 
PROGRAMME DANS CREATE WITH CODE : 
 
PROGRAMME 2 DANS CREATE WITH CODE

ATTENTION RAJOUTER LE STRING DANS display.show(str(nb_spectateurs)) dans https://create.withcode.uk/

-----------------------------------------------------------

PROGRAMME 3 :
La jauge de la salle est de 120 – il faut afficher une image si la salle est pleine – IMAGE SAD par ex 
 
EXERCICE 3.mp4 
 
tp3.mp4 
 
------------------------------------------------------------
 
Programme PYTHON : 

Programme py

Programme hex
 
from microbit import * 
 
nb_spectateurs = 0 
 
# Répéter indéfiniement 
while nb_spectateurs<120: 
if button_a.was_pressed(): 
nb_spectateurs = nb_spectateurs+1 
display.show(nb_spectateurs) 
if button_b.was_pressed(): 
nb_spectateurs = 0 
display.show(Image.SAD) 

 
------------------------------------------------------------
 
PROGRAMME DANS CREATE WITH CODE : 
 
PROGRAMME 3 DANS CREATE WITH CODE

ATTENTION RAJOUTER LE STRING DANS display.show(str(nb_spectateurs)) dans https://create.withcode.uk/

------------------------------------------------------------

PROGRAMME 4 : 
 
tp4.mp4 
 
tp 4 bis.mp4 
 
TESTER LE MODULE RADIO.mp4 
 
Le bouton B remet le compteur à 0 
Cas de plusieurs entrées à la salle de spectacle 
Plusieurs cartes pour compter les personnes 
Une carte centralise le compte total 
Nécessité de connecter nos objets via radio 
 
------------------------------------------------------------
 
Programme PYTHON EMETTEUR : 

Programme py

Programme hex
 
from microbit import * 
import radio 
# Configuration radio 
radio.config(group=1) 
radio.on() 
 
while True: 
if button_a.was_pressed(): 
radio.send("A") 

 
Programme PYTHON RECEPTEUR : 

Programme py

Programme hex
 
from microbit import * 
import radio 
# Configuration radio 
radio.config(group=1) 
radio.on() 
 
nb_spectateurs = 0 
while True: 
if radio.receive() == "A": 
nb_spectateurs = nb_spectateurs+1 
if button_a.was_pressed(): 
display.show(nb_spectateurs) 

 
------------------------------------------------------------ 
 
PROGRAMME DANS CREATE WITH CODE : 
 
EMETTEUR DANS CREATE WITH CODE 
 
ATTENTION RAJOUTER LE STRING DANS display.show(str(nb_spectateurs)) dans https://create.withcode.uk/ 
 
 
RECEPTEUR DANS CREATE WITH CODE 
 
ATTENTION RAJOUTER LE STRING DANS display.show(str(nb_spectateurs)) dans https://create.withcode.uk/

-----------------------------------------------------------

PROGRAMME 5 : 
 
En cas de dépassement de 120 spectateurs, une image triste est affichée sur la carte réceptrice, mais aussi sur les cartes émettrices. 
 
tp 5.mp4 
 
------------------------------------------------------------
 
Programme PYTHON EMETTEUR : 

Programme py

Programme hex
 
from microbit import * 
import radio 
# Configuration radio 
radio.config(group=1) 
radio.on() 
 
while True: 
if button_a.was_pressed(): 
radio.send("A") 
 
if radio.receive() == "Z": 
display.show(Image.SAD) 

 
Programme PYTHON RECEPTEUR :

Programme py

Programme hex 
 
from microbit import * 
import radio 
# Configuration radio 
radio.config(group=1) 
radio.on() 
 
nb_spectateurs = 0 
while True: 
if radio.receive() == "A": 
nb_spectateurs = nb_spectateurs+1 
if nb_spectateurs > 20: 
radio.send("Z") 
display.show(Image.SAD) 
if button_a.was_pressed(): 
display.show(nb_spectateurs) 

 
------------------------------------------------------------
 
PROGRAMME DANS CREATE WITH CODE : 
 
EMETTEUR DANS CREATE WITH CODE

RECEPTEUR DANS CREATE WITH CODE

PROJET 2 - COMMENT REALISER UN AFFICHEUR DE  DIRECTION POUR VELOS ?
DEMARCHE DE PROJET : 
 
Problématique : 
Comment indiquer la direction lors d’une sortie vélo ? 

Présentation du projet
 
Lire le diaporama odt
Lire le diaporama pdf

Document élève odt
Document élève pdf

Fichier stl du feu avec 2 leds

-----------------------------------------------------------

PROGRAMME 1 : 
 
Réaliser un afficheur pour vélos – afin d'annoncer sa direction  
 
Quand on appuie sur A – On tourne à gauche 
 
Quand on appuie sur B – On tourne à droite 
 
Sinon on va tout droit 
 
------------------------------------------------------------ 
 
Programme PYTHON EMETTEUR : 

Programme py

Programme hex
 
from microbit import * 
import radio 
# LES FEUX DE VELO - PROGRAMME EMETTEUR 
# SI ON APPUIE SUR LE BOUTON A ON ENVOIE A PAR ONDES RADIOS 
# SI ON APPUIE SUR LE BOUTON B ON ENVOIE B PAR ONDES RADIOS 
radio.config(group=1) 
radio.config(channel=5) 
radio.on() 
 
while True: 
# ON ENVOIE A PAR ONDES RADIOS A 
if button_a.was_pressed(): 
radio.send("A") 
 
# ON ENVOIE B PAR ONDES RADIOS B 
if button_b.was_pressed(): 
radio.send("B") 


-----------------------------------------------------------
 
Programme PYTHON RECEPTEUR : 

Programme py

Programme hex
 
from microbit import * 
import radio 
# Configuration radio 
radio.config(group=1) 
radio.config(channel=5) 
radio.on() 
 
while True: 
display.show(Image.ARROW_N) 
 
if radio.receive() == "A": 
display.show(Image.ARROW_W) 
sleep(500) 
display.clear() 
 
elif radio.receive() == "B": 
display.show(Image.ARROW_E) 
sleep(500) 
display.clear() 


----------------------------------------------------------

PROGRAMME 2 : 
 
Faire clignoter les fléches 

Présentation du projet
 
------------------------------------------------------------
 
Programme PYTHON EMETTEUR : 

Programme py

Programme hex
 
from microbit import * 
import radio 
# LES FEUX DE VELO - PROGRAMME EMETTEUR 
# SI ON APPUIE SUR LE BOUTON A ON ENVOIE A PAR ONDES RADIOS 
# SI ON APPUIE SUR LE BOUTON B ON ENVOIE B PAR ONDES RADIOS 
radio.config(group=1) 
radio.config(channel=5) 
radio.on() 
 
while True: 
# ON ENVOIE A PAR ONDES RADIOS A 
if button_a.was_pressed(): 
radio.send("A") 
 
# ON ENVOIE B PAR ONDES RADIOS B 
if button_b.was_pressed(): 
radio.send("B") 


-----------------------------------------------------------
 
Programme PYTHON RECEPTEUR : 

Programme py

Programme hex
 
from microbit import * 
import radio 
# Configuration radio 
radio.config(group=1) 
radio.config(channel=5) 
radio.on() 
 
while True: 
i = 0 
while i < 2: 
i = i + 1 
display.show(Image.ARROW_N) 
sleep(200) 
display.clear() 
display.set_pixel(2, 2, 9) 
sleep(100) 
display.clear() 
 
if radio.receive() == "A": 
i = 0 
while i < 5: 
i = i + 1 
display.show(Image.ARROW_W) 
sleep(500) 
display.clear() 
display.set_pixel(2, 2, 9) 
sleep(200) 
display.clear() 
 
if radio.receive() == "B": 
i = 0 
while i < 5: 
i = i + 1 
display.show(Image.ARROW_E) 
sleep(500) 
display.clear() 
display.set_pixel(2, 2, 9) 
sleep(200) 
display.clear() 
display.clear() 


-----------------------------------------------------------

PROGRAMME 3 :  
 
Faire défiler les flèches AVEC DISPLAY SCROLL 
 
Programme PYTHON EMETTEUR : 

Programme py

Programme hex
 
from microbit import * 
import radio 
# LES FEUX DE VELO - PROGRAMME EMETTEUR 
# SI ON APPUIE SUR LE BOUTON A ON ENVOIE A PAR ONDES RADIOS 
# SI ON APPUIE SUR LE BOUTON B ON ENVOIE B PAR ONDES RADIOS 
radio.config(group=1) 
radio.config(channel=5) 
radio.on() 
 
while True: 
# ON ENVOIE A PAR ONDES RADIOS A 
if button_a.was_pressed(): 
radio.send("A") 
 
# ON ENVOIE B PAR ONDES RADIOS B 
if button_b.was_pressed(): 
radio.send("B") 

 
Programme PYTHON RECEPTEUR : 

Programme py

Programme hex
 
from microbit import * 
import radio 
# Configuration radio 
radio.config(group=1) 
radio.config(channel=5) 
radio.on() 
 
while True: 
i = 0 
while i < 2: 
i = i + 1 
display.show(Image.ARROW_N) 
sleep(200) 
display.clear() 
display.set_pixel(2, 2, 9) 
sleep(100) 
display.clear() 
 
if radio.receive() == "A": 
i = 0 
while i < 5: 
i = i + 1 
display.scroll('<') 
sleep(500) 
display.clear() 
 
if radio.receive() == "B": 
i = 0 
while i < 5: 
i = i + 1 
display.scroll('>') 
sleep(500) 
display.clear() 
 
display.clear()


-----------------------------------------------------------

PROGRAMME 4 : 
 
Indiquer la direction par un simple mouvement de la tete – la carte maitre se trouve sur le casque du vélo 
 
INDICE 
 
PROGRAMME SUR UNE SEULE CARTE AVEC L’ACCELEROMETRE : 
 
from microbit import * 
 
while True: 
abscisse = accelerometer.get_x() 
if abscisse > 500: 
display.show(Image.ARROW_E) 
elif abscisse < -500: 
display.show(Image.ARROW_W) 
else: 
display.show(Image.ARROW_N) 

 
------------------------------------------------------------
 
Programme PYTHON EMETTEUR : 

Programme py

Programme hex
 
from microbit import * 
import radio 
# LES FEUX DE VELO - PROGRAMME EMETTEUR 
radio.config(group=1) 
radio.config(channel=5) 
radio.on() 
 
while True: 
abscisse = accelerometer.get_x() 
# ON ENVOIE B PAR ONDES RADIOS 
if abscisse > 500: 
radio.send("B") 
# ON ENVOIE A PAR ONDES RADIOS 
elif abscisse < -500: 
radio.send("A") 

 
Programme PYTHON RECEPTEUR : 

Programme py

Programme hex
 
from microbit import * 
import radio 
# Configuration radio 
radio.config(group=1) 
radio.config(channel=5) 
radio.on() 
 
while True: 
display.show(Image.ARROW_N) 
 
if radio.receive() == "A": 
display.show(Image.ARROW_W) 
sleep(200) 
display.clear() 
 
elif radio.receive() == "B": 
display.show(Image.ARROW_E) 
sleep(200) 
display.clear()


PROJET 3 - COMMENT REALISER UN FEU DE TRAVAUX - UN SEUL FEU ?

PHASE PROJET : 
Comment piloter un feu de chantier ? 
 
------------------------------------------------------------
 
PROGRAMME 1 :
Objet embarqué – 1 seul feux 
 
exercice 1.mp4 
 
Dans ce 1 er exercice – 1 seul feu pour commencer 
Feu rouge allumé – on s’arrête 
Temps d’attente 2 secondes 
Feu rouge éteint – on passe 
Temps d’attente 2 secondes 
 
PROGRAMME 1 : 

Programme py

Programme hex
 
# Appel de la bibliothèque "microbit" 
from microbit import * 
 
# Boucle infinie 
while True: 
# Feu rouge allumé 
pin0.write_digital(1) 
# Attendre 2 secondes 
sleep(2000) 
# Feu rouge éteint 
pin0.write_digital(0) 
# Attendre 2 secondes 
sleep(2000)

PROJET 4 - COMMENT REALISER UN FEU DE TRAVAUX - 2 FEUX ?
PROGRAMME 2 : 
 
exercice 2.mp4 
 
Comment piloter un feu de chantier ? (système embarqué très simple) 
 
Dans ce 2 eme exercice – 2 feux 
Feu rouge – on s’arrête 
Feu orange on passe 
Temps d’attente 2 secondes 
 
PROGRAMME 2 : 

Programme py

Programme hex
 
from microbit import * 
 
# Fonction feu Rouge 
def afficheRouge(): 
pin1.write_digital(1) 
pin0.write_digital(0) 
 
# Fonction feu orange 
def afficheOrange(): 
pin1.write_digital(0) 
pin0.write_digital(1) 
 
while True: 
# Affichage Rouge 
afficheRouge() 
sleep(2000) 
# Affichage Rouge 
afficheOrange() 
sleep(2000)

PROJET 5 - COMMENT REALISER UN FEU DE TRAVAUX - 2 FEUX ?
PROGRAMME 3 : 
 
Comment rajouter l’attente de 10 secondes sur la matrice à LED ? 
 
exercice 3.mp4 

Programme py

Programme hex
 
from microbit import * 
 
# attente de 10 secondes 
DUREE = 10 
attente = DUREE 
feuRouge = True 
 
def afficheRouge(): 
pin1.write_digital(1) 
pin0.write_digital(0) 
 
def afficheOrange(): 
pin1.write_digital(0) 
pin0.write_digital(1) 
 
def afficheAttente(attente): 
display.show(str(attente)) 
 
while True: 
# Affichage Rouge Orange 
if feuRouge: 
afficheRouge() 
else: 
afficheOrange() 
 
# Gestion de l'attente 
sleep(1000) 
attente -= 1 
afficheAttente(attente) 
 
# Alternance du feu 
if attente == 0: 
feuRouge = not feuRouge 
attente = DUREE

PROJET 6 - COMMENT GERER LE FEU UNIQUEMENT AVEC LES PIXELS ?

Comment gérer le feu uniquement avec les PIXELS – en mode virtuel ?

exercice 4.mp4 

Programme py

Programme hex


from microbit import * 
 
# 10 secondes 
DUREE = 10 
attente = DUREE 
feuRouge = True 
 
def afficheRouge(): 
for x in range(3, 5): 
for y in range(2): 
display.set_pixel(x, y, 9) 
for x in range(3, 5): 
for y in range(3, 5): 
display.set_pixel(x, y, 0) 
 
def afficheOrange(): 
for x in range(3, 5): 
for y in range(2): 
display.set_pixel(x, y, 0) 
for x in range(3, 5): 
for y in range(3, 5): 
display.set_pixel(x, y, 4) 
 
def afficheAttente(attente): 
for x in range(2): 
for y in range(5): 
display.set_pixel(x, y, 0 if 5*x+y >= attente else 9) 
 
while True: 
# Affichage Rouge / Orange 
if feuRouge: 
afficheRouge() 
else: 
afficheOrange() 
# Gestion de l'attente 
sleep(1000) 
attente -= 1 
afficheAttente(attente) 
# Alternance du feu 
if attente == 0: 
feuRouge = not feuRouge 
attente = DUREE

PROJET 7 - COMMENT PROGRAMMER LES 2 FEUX EN LIAISON RADIO ?
PROGRAMME 5 : 
 
les feux sont en opposition ! 
Les 2 feux affichent le même compte à rebours 
 
PROGRAMME 5 EMETTEUR : 

Programme py
 
from microbit import * 
 
import radio 
radio.config(group=2) 
radio.on() 
DUREE = 10 
attente = DUREE 
feuRouge = True 
 
def afficheRouge(): 
pin1.write_digital(1) 
pin0.write_digital(0) 
 
def afficheOrange(): 
pin1.write_digital(0) 
pin0.write_digital(1) 
 
def afficheAttente(attente): 
display.show(str(attente)) 
 
while True: 
# Affichage Rouge / Orange 
if feuRouge: 
afficheRouge() 
else: 
afficheOrange() 
# Gestion de l'attente 
sleep(1000) 
attente -= 1 
afficheAttente(attente) 
radio.send(str(attente)) 
# Alternance du feu 
if attente == 0: 
attente = DUREE 
feuRouge = not feuRouge 
if feuRouge: 
radio.send("VERT") 
else: 
radio.send("ROUGE") 

 
PROGRAMME 5 RECEPTEUR : 

Programme py
 
from microbit import * 
 
import radio 
radio.config(group=2) 
radio.on() 
 
feuRouge = True 
 
def afficheRouge(): 
pin1.write_digital(1) 
pin0.write_digital(0) 
 
def afficheOrange(): 
pin1.write_digital(0) 
pin0.write_digital(1) 
 
def afficheAttente(attente): 
display.show(str(attente)) 
 
while True: 
# Traitement des messages 
incoming = radio.receive() 
if incoming: 
if incoming == "VERT": 
feuRouge = False 
elif incoming == "ROUGE": 
feuRouge = True 
elif len(incoming) == 1: 
afficheAttente(int(incoming)) 
# Affichage Rouge / Orange 
if feuRouge: 
afficheRouge() 
else: 
afficheOrange()

PROJET 8 - COMMENT PROGRAMMER LES 2 FEUX EN LIAISON RADIO - MAITRE ESCLAVE ?
Présentation de la maquette de feux

Les fichiers 3D

Les fichiers 3D

PROGRAMME MAITRE :

Programme py

from microbit import * 
from time import ticks_ms 
import radio 
 
radio.config(group=2) 
radio.on() 
 
DUREE = 10 # 10 secondes 
attente = DUREE 
feuRouge = True 
clignotant = ticks_ms() 
 
def afficheRouge(): 
pin1.write_digital(1) 
pin0.write_digital(0) 
 
def afficheOrange(): 
pin1.write_digital(0) 
# orange clignotant 
if ticks_ms()-clignotant < 500: 
pin0.write_digital(1) 
else: 
pin0.write_digital(0) 
 
def afficheAttente(attente): 
display.show(str(attente)) 
 
while True: 
if feuRouge : 
afficheRouge() 
else : 
afficheOrange() 
 
# Action toutes les secondes 
if ticks_ms()-clignotant > 1000: 
clignotant = ticks_ms() 
attente -= 1 
afficheAttente(attente) 
radio.send(str(attente)) 
 
# Alternance du feu 
if attente == 0 : 
attente=DUREE 
feuRouge = not feuRouge 
if feuRouge : 
radio.send("VERT") 
else: 
radio.send("ROUGE")

PROGRAMME ESCLAVE :

Programme py

from microbit import * 
from time import ticks_ms 
import radio 
 
radio.config(group=2) 
radio.on() 
 
feuRouge = True 
clignotant = ticks_ms() 
 
def afficheRouge(): 
pin1.write_digital(1) 
pin0.write_digital(0) 
 
def afficheOrange(): 
pin1.write_digital(0) 
# orange clignotant 
if ticks_ms()-clignotant < 500: 
pin0.write_digital(1) 
else: 
pin0.write_digital(0) 
 
def afficheAttente(attente): 
display.show(str(attente)) 
 
while True: 
# Traitement des messages du maitre 
incoming = radio.receive() 
if incoming: 
if incoming == "VERT" : 
feuRouge = False 
elif incoming == "ROUGE" : 
feuRouge = True 
elif len(incoming)==1: 
afficheAttente(int(incoming)) 
 
# Affichage Rouge / Orange 
if feuRouge : 
afficheRouge() 
else : 
afficheOrange() 
 
# Compteur temps à 0 toute les secondes 
if ticks_ms()-clignotant > 1000: 
clignotant = ticks_ms()