Qu'est-ce que c'est ?
Jouez à pierre, papier, ciseaux avec votre micro:bit et écoutez les effets sonores des différents objets. Les élèves apprendront les notions de randomisation et de sélection dans le cadre de ce projet amusant.

Comment ça marche
- Pierre, feuille, ciseaux est un jeu de hasard pour deux personnes. Vous et un partenaire serrez vos poings trois fois, puis faites un geste aléatoire pour représenter soit une pierre (poing), soit du papier (main à plat), soit des ciseaux (forme de ciseaux). La pierre bat les ciseaux, les ciseaux battent le papier et le papier bat la pierre.
- Ce programme permet au micro:bit de choisir pour vous entre pierre, papier ou ciseaux. Téléchargez le programme sur deux micro:bits et connectez deux blocs d'alimentation. Vous et votre partenaire devez ensuite secouer vos micro:bits pour voir apparaître deux images aléatoires, une sur chaque micro:bit.
- Vous entendrez également différents effets sonores pour le jeu de pierre, de papier et de ciseaux. A rock makes a 'sad' sound, paper makes a 'hello' sound, and scissors makes a 'mysterious' sound.
- The program uses a variable called ‘tool’. Variables are containers for storing data, which can be accessed and updated while a program is running. The variable ‘tool’ is used to store random numbers.
- When the micro:bit accelerometer detects a shake movement, it sets the variable ‘tool’ to a random number: 0, 1 or 2. Le programme utilise 0 car les ordinateurs commencent à compter à 0.
- The program uses selection to decide what image to show on the LED display and what expressive sound to play.
- If the random number was 0, it shows a rock icon (a small square) and plays the ‘sad’ sound. If it was 1, it shows the icon representing paper (a square) and plays the ‘hello’ sound. If it wasn’t 0 or 1, it must be 2 because we instructed the micro:bit to only pick random numbers between 0 and 2, so in that case it shows scissors and plays the 'mysterious' sound.
Ce dont vous aurez besoin
- un micro:bit V2
- L'éditeur MakeCode
- coupleur de piles
Codez votre projet
Voici les blocs dont vous avez besoin pour faire le projet - il faut maintenant les mettre ensemble.
Instructions étape par étape
- Ouvrez le projet pour trouver les blocs dont vous avez besoin en utilisant les boutons ci-dessus.
- Find the pick random 0 to 2 block and put it onto the 0 in the set tool to 0 block.
- Get the set tool to pick random 0 to 2 block and put it inside the on shake block. Now when you shake your micro:bit, it will pick a random number between 0 and 2 and store it in the tool variable.
- Vous devez maintenant écrire le code relatif à la sélection. Get the if then else block and put it inside the on shake block under the set tool to pick random 0 to 2 block.
- Get the show icon small square block and put it under if tool = 0 then in the if then else block.
- Then find the play sad until done block and put it directly under the show icon small square block. Votre micro:bit affichera désormais un petit carré ou une pierre et émettra le son ‘triste‘ si le nombre aléatoire choisi est 0.
- Now find the show icon square block and put it under else if tool = 1 then in the if then else block.
- Get the play hello until done block and put it directly underneath the show icon square block. Votre micro:bit affichera un carré et émettra le son ‘hello‘ si le nombre aléatoire choisi est 1.
- Next get the show icon scissors block and put it under else in the if then else block. Placez le bloc jouer mystérieux jusqu'à la fin directement en dessous. Votre micro:bit affichera désormais une icône de ciseaux et émettra un son ‘mystérieux‘ lorsque le nombre aléatoire choisi sera 2.
Personnalisez-le
- Choose your own expressive sounds to play for the different objects by using the drop-down in the play sound until done blocks. Il y en a 10 au choix.
- Use other icons from the show icon block such as the giraffe, duck, skull and ghost by using the drop-down option. Inventez de nouvelles règles pour le jeu.
Exemple de projet réalisé
Jetez un coup d'œil à un extrait de code finalisé.
Projets associés
Ce projet fait partie d'une collection de projets inclusifs avec des sons et des images.


