Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
- Committer:
- algrs
- Date:
- 2022-02-22
- Revision:
- 0:1f73ccb6b75d
File content as of revision 0:1f73ccb6b75d:
#include "mbed.h" DigitalIn boutonPierre(p5); DigitalIn boutonFeuille(p6); DigitalIn boutonCiseaux(p7); DigitalOut LED_R(p18); DigitalOut LED_B(p19); DigitalOut LED_G(p20); int main() { int variablePierre=0, variablePierreAVANT=0; int variableFeuille=0, variableFeuilleAVANT=0; int variableCiseaux=0, variableCiseauxAVANT=0; int choixJoueur=3; int choixOrdi=3; int bonjour = 0 ; // variable victoire bravo leo puts("\n\r DEBUT DU PROGRAMME \n\r__________________ \n\r"); LED_R.write(0); LED_G.write(0); LED_B.write(0); while(1) { wait(0.7); printf("\n\r************ Choisissez pierre/feuille/ciseaux :\n\r(VICTOIRES = %d ) n\r",bonjour); while (1) { variablePierreAVANT = variablePierre; variablePierre = boutonPierre.read(); variableFeuilleAVANT = variableFeuille; variableFeuille = boutonFeuille.read(); variableCiseauxAVANT = variableCiseaux; variableCiseaux = boutonCiseaux.read(); choixJoueur=3; choixOrdi=3; if(variablePierre>variablePierreAVANT) { printf("Vous avez choisi PIERRE\n\r"); choixJoueur=0; break; } else if(variableFeuille>variableFeuilleAVANT) { printf("Vous avez choixi FEUILLE !\n\r"); choixJoueur=1; break; } else if(variableCiseaux>variableCiseauxAVANT) { printf("Vous avez choisi CISEAUX !\n\r"); choixJoueur=2; break; } wait(0.001); } LED_R.write(0); LED_G.write(0); LED_B.write(1); wait(0.7); choixOrdi= rand() % 3 ; switch(choixOrdi) { case 0: printf("L'ordi a choisi PIERRE !\n\r"); break; case 1: printf("L'ordi a choisi FEUILLE !\n\r"); break; case 2: printf("L'ordi a choisi CISEAUX !\n\r"); break; default: choixOrdi=3; break; } wait(0.7); if(choixJoueur==choixOrdi) { printf("EGALITE !\n\r"); LED_R.write(1); LED_G.write(1); LED_B.write(1); } else if((choixJoueur==0 && choixOrdi==2 )||(choixJoueur==1 && choixOrdi==0 )||(choixJoueur==2 && choixOrdi==1 )) { printf("Vous avez GAGNE !\n\r"); bonjour=bonjour+1; LED_R.write(0); LED_G.write(1); LED_B.write(0); } else if((choixOrdi==0 && choixJoueur==2 )||(choixOrdi==1 && choixJoueur==0 )||(choixOrdi==2 && choixJoueur==1 )) { printf("Vous avez PERDU !\n\r"); LED_R.write(1); LED_G.write(0); LED_B.write(0); } else { printf("\n\rErreur"); LED_R.write(0); LED_G.write(0); LED_B.write(0); break; } } puts("\n\r FIN DU PROGRAMME \n\r"); return 0; }