Fabrication industrielle
Internet des objets industriel | Matériaux industriels | Entretien et réparation d'équipement | Programmation industrielle |
home  MfgRobots >> Fabrication industrielle >  >> Manufacturing Technology >> Processus de fabrication

Arduino Due TIC TAC TOE avec écran tactile

Composants et fournitures

Arduino Due
× 1
LCD TFT 2,8 zoll avec écran tactile
× 1
Câbles de raccordement (générique)
× 1

Applications et services en ligne

Arduino IDE

À propos de ce projet

À propos

Bonjour, je souhaite partager mon travail sur le projet de nickthegreek82 :arduino-touch-tic-tac-toe-game.

Vous avez besoin de :

  • la bibliothèque Adafruit
  • la bibliothèque GFX
  • et la bibliothèque URTouch

Câblage

Le câblage est le suivant pour l'écran tactile :

  • Touchez -> Arduino Due
  • T_IRQ -> 22
  • T_DO -> 24
  • T_DIN -> 26
  • T_CS -> 28
  • T_CLK -> 30

Pour l'affichage :

  • Affichage -> Arduino Due
  • SDO -> A.25
  • LED -> 3,3 V
  • SCK -> A.27
  • SDI -> A.26
  • DC -> 9
  • RÉINITIALISER -> 8
  • CS -> 10
  • GND -> GND
  • VCC -> 3,3 V

22.08.2017

Modification du KI et optimisation du code.

26.08.2017

Quelques optimisations de code.

27.08.2017

Pouvez-vous gagner contre le CPU?

13.03.2018

trouvé un meilleur moyen pour l'IA.

merci à klauscam https://github.com/klauscam/ArduinoTicTacToe

Code

  • TIC TAC TOE
  • TicTacToe_new
TIC TAC TOEArduino
Un jeu de TIC TAC TOE simple à jouer contre l'ordinateur ////////////////////////////////// ///////// // ECRAN TACTILE 2.8" TIC TAC TOE // // // // http://www.educ8s.tv // // // // modifié le 08.2017 par rom3 // / /////////////////////////////////////////#include #include #include #include #include #define TFT_RST 8#define TFT_DC 9#define TFT_CS 10#define TOUCH_ORIENTATION LANDSCAPEAdafruitt_ILI939341dafruit_ILI93 (TFT_CS, TFT_DC, TFT_RST);boutons Adafruit_GFX_Button[9];URTouch myTouch (30, 28, 26, 24, 22); mouvements int courts non signés =1; gagnant int court non signé =0; //0 =tirage, 1 =Human, 2 =CPUunsigned short int x,y ; // position touchunsigned short int cursor ; // position du curseur unsigned short int firstMoves[]={0,2,6,8} ; // utilisera ces positions en premier, si le CPU commence sans signe short int board[] ={0,0,0,0,0,0,0,0,0} ;// contient les données de position 0 est vide, 1 humain, 2 est un joueur de computerbool ; // vrai=VOUS, faux =CPUbo olb=1; char start[10] ={"Gamestart"};char you[4] ={"VOUS"};char cpu[4] ={"CPU"};char again[7] ={"Encore?"}; const unsigned char circle[]PROGMEM={0b0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 ,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 ,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0xf8,0x0,0x0,0x0 ,0x0,0x0,0x0,0x0,0x7f,0xff,0x80,0x0,0x0,0x0,0x0,0x0,0x3,0xff,0xff,0xf0,0x0,0x0,0x0,0x0,0x0,0xf,0xff,0xff,0xfc ,0x0,0x0,0x0,0x0,0x0,0x1f,0xff,0xff,0xfe,0x0,0x0,0x0,0x0,0x0,0x7f,0xf0,0x3,0xff,0x80,0x0,0x0,0x0,0x0,0xff,0x80 ,0x0,0x7f,0xc0,0x0,0x0,0x0,0x1,0xfe,0x0,0x0,0x1f,0xe0,0x0,0x0,0x0,0x3,0xf8,0x0,0x0,0x7,0xf0,0x0,0x0,0x0,0x7 ,0xf0,0x0,0x0,0x3,0xf8,0x0,0x0,0x0,0xf,0xe0,0x0,0x0,0x1,0xfc,0x0,0x0,0x0,0xf,0xc0,0x0,0x0,0x0,0xfc,0x0,0x0 ,0x0,0x1f,0x80,0x0,0x0,0x0,0x7e,0x0,0x0,0x0,0x3f,0x0,0x0,0x0,0x0,0x3f,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0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 ,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};void setup() { myTouch.InitTouch(); myTouch.setPrecision(PREC_HI); tft.begin(); tft.setRotation(3) ; tft.fillScreen(ILI9341_BLACK); //Dessiner le cadre blanc tft.drawRect(0,0,320,240,ILI9341_WHITE); //Imprime le texte "Arduino" tft.setCursor(80,30); tft.setTextColor(ILI9341_GREEN); tft.setTextSize(4) ; tft.print("Arduino"); //Imprimer le texte "Tic Tac Toe" tft.setCursor(30,100); tft.setTextColor(ILI9341_WHITE); tft.setTextSize(4) ; tft.print("Tic Tac Toe"); //Créer un bouton rouge // créer des boutons // x, y, l, h, contour, remplissage, boutons de texte[0].initButton(&tft, 160,200,200,40,ILI9341_WHITE, ILI9341_RED, ILI9341_WHITE, start, 2); boutons[0].drawButton();do{ waitonetouch(&x,&y); if (boutons[0].contains(x,y)) b=0;}while(b>0) ; }boucle vide() { for(unsigned short int i=0;i<9;i++) { board[i]=0; } tft.fillScreen(ILI9341_BLACK); //Dessiner le cadre blanc tft.drawRect(0,0,320,240,ILI9341_WHITE); //Imprimer le texte "Tic Tac Toe" tft.setCursor(30,30); tft.setTextColor(ILI9341_WHITE); tft.setTextSize(4) ; tft.print("Tic Tac Toe"); //Imprimez "YouTube !" texte tft.setCursor(30 100); tft.setTextColor(ILI9341_GREEN); tft.setTextSize(4) ; tft.print("Qui commence"); //Créer un bouton rouge // créer des boutons // x, y, l, h, contour, remplissage, boutons de texte[0].initButton(&tft, 100,200,80,40,ILI9341_WHITE, ILI9341_RED, ILI9341_WHITE, vous, 2); boutons[0].drawButton(); // créer des boutons // x, y, l, h, contour, remplissage, boutons de texte[1].initButton(&tft, 200,200,80,40,ILI9341_WHITE, ILI9341_RED, ILI9341_WHITE, cpu, 2); boutons[1].drawButton(); b=1 ; do{ waitonetouch(&x,&y); if (boutons[0].contains(x,y)) { b=0; joueur =1 ; tft.fillScreen(ILI9341_BLACK); //Dessiner le cadre blanc tft.drawRect(0,0,320,240,ILI9341_WHITE); tft.setCursor(30,30); tft.setTextColor(ILI9341_WHITE); tft.setTextSize(2) ; tft.print("D'accord, vous commencez."); retard (2000); } if(boutons[1].contient(x,y)) { b=0; joueur =0 ; tft.fillScreen(ILI9341_BLACK); //Dessiner le cadre blanc tft.drawRect(0,0,320,240,ILI9341_WHITE); tft.setCursor(30,30); tft.setTextColor(ILI9341_WHITE); tft.setTextSize(2) ; tft.print("D'accord, le processeur commence."); retard (2000); } } tandis que(b>0) ; b=1 ; mouvements =1 ; gagnant =0 ; curseur =10 ; tft.fillScreen(ILI9341_BLACK); //Dessiner le cadre tft.drawRect(0,0,320,240,ILI9341_WHITE); //Tracer la ligne verticale tft.fillRect(80,15,5,205,ILI9341_WHITE); tft.fillRect(150,15,5,205,ILI9341_WHITE); //Tracer la ligne horizontale tft.fillRect(15,80,205,5,ILI9341_WHITE); tft.fillRect(15,150,205,5,ILI9341_WHITE); tft.drawRect(230,10,80,220,ILI9341_WHITE); { do { if(moves%2==1 &&player==false || move%2==0 &&player==true) { curseur+=10; tft.setCursor(240,cursor); tft.setTextSize(1) ; tft.println("Je dessine"); arduinoMove(); checkWinner(); } else { curseur+=10; tft.setCursor(240,cursor); tft.setTextSize(1) ; tft.println("Votre coup"); playerMove(); checkWinner(); } délai(1000); bouge++; }pendant que (gagnant==0 &&bouge<10) ; waitonetouch(&x,&y); tft.fillScreen(ILI9341_BLACK); //Dessiner le cadre tft.drawRect(0,0,320,240,ILI9341_WHITE); //Imprimer le texte "Game Over" tft.setCursor (50,30); tft.setTextColor(ILI9341_WHITE); tft.setTextSize(4) ; tft.print("GAME OVER"); if(gagnant ==0){ //Imprimer " DESSIN !" texte tft.setCursor(110,100); tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(4) ; tft.print("DRAW");} if(winner ==1){ //Imprimer "HUMAN WINS!" texte tft.setCursor (40 100); tft.setTextColor(ILI9341_BLUE); tft.setTextSize(4) ; tft.print("HUMAN WINS");} if(winner ==2){ //Imprimer "CPU WINS!" texte tft.setCursor(60,100); tft.setTextColor(ILI9341_RED); tft.setTextSize(4) ; tft.print("CPU WINS");} // création de boutons // x, y, w, h, contour, remplissage, boutons de texte[0].initButton(&tft, 160,200,200,40,ILI9341_WHITE, ILI9341_RED, ILI9341_WHITE, encore une fois , 2); boutons[0].drawButton(); do{ waitonetouch(&x,&y); if (boutons[0].contains(x,y)) b=0; }tandis(b>0) ; }} void playerMove(){ waitonetouch(&x,&y); if((x>15 &&x<85) &&(y>15 &&y<85)) //0 { if(board[0]==0) { board[0]=1; dessinerX(15,15); } else erreur(); } else if((x>85 &&x<155)&&(y>15 &&y<85)) //1 { if(board[1]==0) { board[1]=1; dessinerX(85,15); } else erreur(); } if((x>155 &&x<225)&&(y>15 &&y<85)) //2 { if(board[2]==0) { board[2]=1; dessinerX(155,15); } else erreur(); } if((x>15 &&x<85)&&(y>85 &&y<155)) //3 { if(board[3]==0) { board[3]=1; dessinerX(15,85); } else erreur(); } if((x>85 &&x<155)&&(y>85 &&y<155)) //4 { if(board[4]==0) { board[4]=1; dessinerX(85,85); } else erreur(); } if((x>155 &&x<225)&&(y>85 &&y<155)) //5 { if(board[5]==0) { board[5]=1; dessinerX(155,85); } else erreur(); } if((x>15 &&x<85)&&(y>155 &&y<225)) //6 { if(board[6]==0) { board[6]=1; dessinerX(15,155) ; } else erreur(); } if((x>85 &&x<155)&&(y>155 &&y<225)) //7 { if(board[7]==0) { board[7]=1; dessinerX(85,155) ; } else erreur(); } if((x>155 &&x<225)&&(y>155 &&y<225)) //8 { if(board[8]==0) { board[8]=1; dessinerX(155,155) ; } else erreur(); }}erreur vide(){ curseur+=10; tft.setCursor(240,cursor); tft.setTextSize(1) ; tft.println("Erreur"); retard(1000); curseur+=10; tft.setCursor(240,cursor); tft.println("Essayez à nouveau."); playerMove();}unsigned short int checkOpponent(unsigned short int x, unsigned short int y){ if(board[1]==x &&board[2]==x &&board[0]==y){ if( y==0){ renvoie 0 ; } sinon renvoie 1 ; } if(board[3]==x &&board[6]==x &&board[0]==y){ if(y==0){ return 0; } sinon renvoie 6 ; } if(board[0]==y &&board[4]==x &&board[8]==x){ if(y==0){ return 0; } sinon renvoie 8 ; } if(board[0]==x &&board[1]==y &&board[2]==x){ if(y==0){ return 1; } sinon renvoie 0 ; } if(board[4]==x &&board[7]==x &&board[1]==y){ if(y==0){ return 1; } sinon renvoie 7 ; } if(board[0]==x &&board[1]==x &&board[2]==y){ if(y==0){ return 2; } sinon renvoie 0 ; } if(board[5]==x &&board[8]==x &&board[2]==y){ if(y==0){ return 2; } sinon renvoie 8 ; } if(board[4]==x &&board[6]==x &&board[2]==y){ if(y==0){ return 2; } sinon renvoie 6 ; } if(board[4]==x &&board[5]==x &&board[3]==y){ if(y==0){ return 3; } sinon renvoie 5 ; } if(board[0]==x &&board[6]==x &&board[3]==y){ if(y==0){ return 3; } sinon renvoie 6 ; } if(board[3]==x &&board[4]==y &&board[5]==x){ if(y==0){ return 4; } sinon renvoie 3 ; } if(planche[1]==x &&planche[7]==x &&planche[4]==y){ if(y==0){ return 4; } sinon renvoie 1 ; } if(board[0]==x &&board[8]==x &&board[4]==y){ if(y==0){ return 4; } sinon renvoie 0 ; } if(board[2]==x &&board[6]==x &&board[4]==y){ if(y==0){ return 4; } sinon renvoie 2 ; } if(board[3]==x &&board[4]==x &&board[5]==y){ if(y==0){ return 5; } sinon renvoie 3 ; } if(board[2]==x &&board[8]==x &&board[5]==y){ if(y==0){ return 5; } sinon renvoie 2 ; } if(board[7]==x &&board[8]==x &&board[6]==y){ if(y==0){ return 6; } sinon renvoie 8 ; } if(board[0]==x &&board[3]==x &&board[6]==y){ if(y==0){ return 6; } sinon renvoie 0 ; } if(board[4]==x &&board[2]==x &&board[6]==y){ if(y==0){ return 6; } sinon renvoie 2 ; } if(planche[1]==x &&planche[4]==x &&planche[7]==y){ if(y==0){ return 7; } sinon renvoie 1 ; } if(planche[6]==x &&planche[8]==x &&planche[7]==y){ if(y==0){ return 7; } sinon renvoie 6 ; } if(board[6]==x &&board[7]==x &&board[8]==y){ if(y==0){ return 8; } sinon renvoie 6 ; } if(board[5]==x &&board[2]==x &&board[8]==y){ if(y==0){ return 8; } sinon renvoie 2 ; } if(board[4]==x &&board[0]==x &&board[8]==y){ if(y==0){ return 8; } sinon renvoie 0 ; } else return 100;}void arduinoMove(){ if(moves<2) { do{ unsigned short int randomMove =random(4); int court non signé c=firstMoves[randomMove] ; if(planche[c]==0){ planche[c]=2; drawCpuMove(firstMoves[randomMove]); retourner; } } while(moves<2) ; } if(moves<3) { if(board[4]==0) { board[4]=2; drawCpuMove(4) ; retourner; } } unsigned short int twoPlayer =checkOpponent(2,0) ;//CPU deux de suite ? if(twoPlayer <9) { board[twoPlayer]=2; drawCpuMove(twoPlayer); retourner; } unsigned short int nextMove =checkOpponent(1,0) ; // Joueur deux de suite ? if(nextMove <9) { board[nextMove]=2; drawCpuMove(nextMove); retourner; } short int non signé suivant =checkOpponent(0,2); if(suivant <9) { tableau[suivant]=2; drawCpuMove(next); retourner; } do { unsigned short int randomMove =random(9); if (board[randomMove]==0) { board[randomMove]=2; drawCpuMove(randomMove); retourner; } }while(nextMove ==100);} void drawCircle(unsigned short int x, unsigned short int y){ tft.drawBitmap(x,y,circle,65,65,ILI9341_RED);}void drawX(unsigned short int x , unsigned short int y){ tft.drawBitmap(x,y,x_bitmap,65,65,ILI9341_BLUE);}void drawCpuMove(unsigned short int move){ switch(move) { case 0:drawCircle(15,15); Pause; cas 1 :drawCircle(85,15); Pause; cas 2:drawCircle(155,15); Pause; cas 3:drawCircle(15,85); Pause; cas 4:drawCircle(85,85); Pause; cas 5:drawCircle(155,85); Pause; cas 6 : drawCircle(15,155) ; Pause; cas 7 : drawCircle(85,155) ;break ; cas 8 : drawCircle(155,155) ;break ; }} void checkWinner() // vérifie le tableau pour voir s'il y a un gagnant // place le résultat dans la variable globale 'winner'{ // rien ne gagne ? if (board[0]>0 &&board[1]==board[0] &&board[2]==board[0]) { winner=board[0]; tft.fillRect(15, 45, 205, 5, ILI9341_WHITE); } if (board[3]>0 &&board[4]==board[3] &&board[5]==board[3]) { winner=board[3]; tft.fillRect(15, 115, 205, 5, ILI9341_WHITE); } if (tableau[6]>0 &&tableau[7]==tableau[6] &&tableau[8]==tableau[6]) { gagnant=tableau[6]; tft.fillRect(15, 185, 205, 5, ILI9341_WHITE); } if (board[0]>0 &&board[3]==board[0] &&board[6]==board[0]) { winner=board[0]; tft.fillRect(45, 15, 5, 205, ILI9341_WHITE); } if (tableau[1]>0 &&tableau[4]==tableau[1] &&tableau[7]==tableau[1]) { winner=tableau[1]; tft.fillRect(115, 15, 5, 205, ILI9341_WHITE); } if (board[2]>0 &&board[5]==board[2] &&board[8]==board[2]) { winner=board[2]; tft.fillRect(185, 15, 5, 205, ILI9341_WHITE); } if (board[0]>0 &&board[4]==board[0] &&board[8]==board[0]) { winner=board[0]; for(unsigned short int xx=0;xx<6;xx++){ tft.drawLine(20+xx, 20, 210+xx, 210, ILI9341_WHITE); } } if (board[2]>0 &&board[4]==board[2] &&board[6]==board[2]) { winner=board[2]; for(unsigned short int xx=0;xx<6;xx++){ tft.drawLine(210+xx, 20, 20+xx, 210, ILI9341_WHITE); } }}void waitonetouch(unsigned short int *x,unsigned short int *y){ do { delay(10); if (myTouch.dataAvailable() ==true) { myTouch.read(); *x =monTouche.getX(); //Obtenir le point de contact *y =myTouch.getY(); retourner; } }while(myTouch.dataAvailable()==false); }
TicTacToe_newArduino
Un solo invincible de Tic Tac Toe sur Arduino Due
 /////////////////////////////////// //////// // ECRAN TACTILE 2.8" TIC TAC TOE // // // // http://www.educ8s.tv // // // // modifié le 08.2017 par rom3 // // ////////////////////////////////////////#include  #include #include #include #define TFT_RST 8#define TFT_DC 9#define TFT_CS 10#define TOUCH_ORIENTATION LANDSCAPEAdafruit_ILI9341 tft =Adafruit_TFT_ILI9341); [9];URTouch myTouch(30, 28, 26, 24, 22);char start[10] ={"Gamestart"};char you[4] ={"VOUS"};char cpu[4] ={" CPU"};char again[7] ={"Again?"};int player;int difficult=8;unsigned short int x,y,b; // position touch#define BLACK 0x0000#define BLUE 0x001F#define RED 0xF800 #define VERT 0x07E0#define CYAN 0x07FF#define MAGENTA 0xF81F#define YELLOW 0xFFE0#define WHITE 0xFFFFint board[]={0,0,0,0,0,0,0,0,0};// contient les données de position 0 est vide, 1 humain, 2 est un tour non signé par ordinateur ; c onst car circle []PROGMEM={0b0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 ,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 ,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0xf8,0x0,0x0,0x0 ,0x0,0x0,0x0,0x0,0x7f,0xff,0x80,0x0,0x0,0x0,0x0,0x0,0x3,0xff,0xff,0xf0,0x0,0x0,0x0,0x0,0x0,0xf,0xff,0xff,0xfc ,0x0,0x0,0x0,0x0,0x0,0x1f,0xff,0xff,0xfe,0x0,0x0,0x0,0x0,0x0,0x7f,0xf0,0x3,0xff,0x80,0x0,0x0,0x0,0x0,0xff,0x80 ,0x0,0x7f,0xc0,0x0,0x0,0x0,0x1,0xfe,0x0,0x0,0x1f,0xe0,0x0,0x0,0x0,0x3,0xf8,0x0,0x0,0x7,0xf0,0x0,0x0,0x0,0x7 ,0xf0,0x0,0x0,0x3,0xf8,0x0,0x0,0x0,0xf,0xe0,0x0,0x0,0x1,0xfc,0x0,0x0,0x0,0xf,0xc0,0x0,0x0,0x0,0xfc,0x0,0x0 ,0x0,0x1f,0x80,0x0,0x0,0x0,0x7e,0x0,0x0,0x0,0x3f,0x0,0x0,0x0,0x0,0x3f,0x0,0x0,0x0,0x3e,0x0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0x0,0x0, 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};void setup(){myTouch.InitTouch(); myTouch.setPrecision(PREC_HI); tft.begin(); tft.setRotation(3);}boucle vide(){ int board[9] ={0,0,0,0,0,0,0,0,0}; drawStartScreen(); faire{ monTouche.read(); x =monTouche.getX(); //Obtenir le point de contact y =myTouch.getY(); retard (100); }while(!(boutons[0].contains(x,y))); tft.fillScreen(NOIR); // Dessiner un cadre blanc tft.drawRect(0,0,320,240,WHITE); //Imprimer le texte "Tic Tac Toe" tft.setCursor(30,30); tft.setTextColor(BLANC); tft.setTextSize(4) ; tft.print("Tic Tac Toe"); //Imprimez "YouTube !" texte tft.setCursor(30 100); tft.setTextColor(GREEN); tft.setTextSize(4) ; tft.print("Qui commence"); //Créer un bouton rouge // créer des boutons // x, y, l, h, contour, remplissage, boutons de texte[0].initButton(&tft, 100,200,80,40,WHITE, RED, WHITE, you, 2); boutons[0].drawButton(); // créer des boutons // x, y, l, h, contour, remplissage, boutons de texte[1].initButton(&tft, 200,200,80,40,WHITE, RED, WHITE, cpu, 2); boutons[1].drawButton(); b=1 ; faire{ monTouche.read(); x =monTouche.getX(); //Obtenir le point de contact y =myTouch.getY(); if (boutons[0].contains(x,y)) { b=0; joueur =1 ; tft.fillScreen(NOIR); // Dessiner un cadre blanc tft.drawRect(0,0,320,240,WHITE); tft.setCursor(30,30); tft.setTextColor(BLANC); tft.setTextSize(2) ; tft.print("D'accord, vous commencez."); retard (2000); } if(boutons[1].contient(x,y)) { b=0; joueur =2 ; tft.fillScreen(NOIR); // Dessiner un cadre blanc tft.drawRect(0,0,320,240,WHITE); tft.setCursor(30,30); tft.setTextColor(BLANC); tft.setTextSize(2) ; tft.print("D'accord, le processeur commence."); retard (2000); } }pendant que(b); tft.fillScreen(NOIR); tft.drawRect(0,0,319,240,BLANC); drawVerticalLine(125); drawVerticalLine(195); dessinerLigneHorizontale(80); dessinerLigneHorizontale(150); for(turn =0; turn <9 &&win(board) ==0; ++turn) { if((turn+player) % 2 ==0) computerMove(board); else { //dessiner (tableau); playerMove(tableau); } } switch(win(board)) { case 0:Serial.println("C'est un match nul.\n"); Pause; cas 1 ://dessiner (planche); Serial.println("Vous perdez.\n"); Pause; case -1 :Serial.println("Vous gagnez !\n"); Pause; } do{}while(myTouch.dataAvailable()==false); //x =map(tp.y, 930, 88, 0, 480); //y =map(tp.x, 908, 125, 0, 320); //delay(250);} }void drawHorizontalLine(int y){ int i=0; for(i=0;i<7;i++) { tft.drawLine(60,y+i,270,y+i,BLANC); }}void drawVerticalLine(int x){ int i=0; for(i=0;i<7;i++) { tft.drawLine(x+i,20,x+i,220,BLANC); }}void drawStartScreen(){ tft.fillScreen(BLACK); // Dessiner un cadre blanc tft.drawRect(0,0,319,240,WHITE); //Imprimer le texte "Tic Tac Toe" tft.setCursor(30,100); tft.setTextColor(BLANC); tft.setTextSize(4) ; tft.print("Tic Tac Toe"); //Imprimez "YouTube !" texte tft.setCursor(80,30); tft.setTextColor(GREEN); tft.setTextSize(4) ; tft.print("Arduino"); boutons[0].initButton(&tft, 160,200,200,40,BLANC, ROUGE, BLANC, démarrer, 2); boutons[0].drawButton(); }void drawCircle(int x, int y){ drawBitmap(x,y,circle,65,65,RED);}void drawX(int x, int y){ drawBitmap(x,y,x_bitmap,65,65,BLUE );}void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_th, uint16_t color) { int16_t i, j, byteWidth =(w + 7) / 8; uint8_t octet ; for(j=0; j score) { score =tempScore; déplacer =je; } } } // renvoie un score basé sur l'arbre minimax à un nœud donné. planche[déplacer] =1 ; drawCpuMove(move); delay(100);}void playerMove(int board[9]) { int move =0; b =1 ; do{ if (myTouch.dataAvailable() ==true) { myTouch.read(); x =monTouche.getX(); //Obtenir le point de contact y =myTouch.getY(); if((x>55 &&x<125)&&(y>0 &&y<80)) //0 { if(board[0]==0) { move=0; b=0 ; } } else if((x>125 &&x<195) &&(y>0 &&y<80)) //1 { if(board[1]==0) { move=1; b=0 ; } } else if((x>195&&x<265)&&(y>0 &&y<80)) //2 { if(board[2]==0) { move=2; b=0 ; } } else if((x>55 &&x<125)&&(y>80 &&y<155)) //3 { if(board[3]==0) { move=3; b=0 ; } } else if((x>125 &&x<195)&&(y>80 &&y<155)) //4 { if(board[4]==0) { move=4; b=0 ; } } else if((x>195&&x<265)&&(y>80 &&y<155)) //5 { if(board[5]==0) { move=5; b=0 ; } } else if((x>55 &&x<125)&&(y>155 &&y<235)) //6 { if(board[6]==0) { move=6; b=0 ; } } else if((x>125 &&x<195)&&(y>155 &&y<235)) //7 { if(board[7]==0) { move=7; b=0 ; } } else if((x>195&&x<265)&&(y>155 &&y<235)) //8 { if(board[8]==0) { move=8; b=0 ; } } } } while(b); planche[déplacer] =-1; drawPlayerMove(move); delay(100);}int win(const int board[9]) { //liste des positions gagnantes possibles unsigned wins[8][3] ={{0,1,2},{3,4,5}, {6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8},{2,4,6}} ; int winPos; for(winPos =0; winPos <8; ++winPos) { if(board[wins[winPos][0]] !=0 &&board[wins[winPos][0]] ==board[wins[winPos][ 1]] &&board[wins[winPos][0]] ==board[wins[winPos][2]]) return board[wins[winPos][2]]; } return 0;}int minimax(int ​​board[9], int player, int depth) { //vérifier les positions des joueurs int winner =win(board); if(winner !=0) return winner*player ; mouvement int =-1; score entier =-2 ; int je; for(i =0; i <9; ++i) { if(board[i] ==0) { board[i] =joueur; int thisScore=0; if (profondeur score) { score =thisScore; déplacer =je; } //choisir le pire coup pour l'adversaire board[i] =0; } } if(move ==-1) return 0; return score;}void drawCpuMove(int move){ switch(move) { case 0:drawCircle(55,15); Pause; cas 1 :drawCircle(130,15); Pause; cas 2:drawCircle(205,15); Pause; cas 3 :drawCircle (55,85); Pause; cas 4:drawCircle(130,85); Pause; cas 5:drawCircle(205,85); Pause; cas 6 : drawCircle(55 155) ; Pause; cas 7 : drawCircle(130,155) ;break ; cas 8 : drawCircle(205,155) ;break ; }}void drawPlayerMove(int move){ switch(move) { case 0:drawX(55,15); Pause; cas 1 :drawX(130,15); Pause; cas 2 :drawX(205,15); Pause; cas 3 : drawX(55,85); Pause; cas 4:drawX(130,85); Pause; cas 5:drawX(205,85); Pause; cas 6 : drawX(55,155) ; Pause; cas 7 : drawX(130,155) ; casser ; cas 8 : drawX(205,155) ; casser ; }}

Schémas

Câblage

Processus de fabrication

  1. Carte de visite du jeu Tic Tac Toe
  2. Surveillance du CO2 avec le capteur K30
  3. Communication sourds-aveugles avec 1Sheeld/Arduino
  4. Contrôler l'accepteur de pièces avec Arduino
  5. Arduino avec Bluetooth pour contrôler une LED !
  6. Capteur d'empreintes digitales capacitif avec un Arduino ou ESP8266
  7. Jouer avec Nextion Display
  8. Bras robotique contrôlé par Nunchuk (avec Arduino)
  9. Mesure du rayonnement solaire avec Arduino