Industrielle Fertigung
Industrielles Internet der Dinge | Industrielle Materialien | Gerätewartung und Reparatur | Industrielle Programmierung |
home  MfgRobots >> Industrielle Fertigung >  >> Manufacturing Technology >> Herstellungsprozess

Arduino Due TIC TAC TOE mit Touchscreen

Komponenten und Verbrauchsmaterialien

Arduino Due
× 1
2,8 Zoll TFT LCD mit Touchscreen
× 1
Jumper (generisch)
× 1

Apps und Onlinedienste

Arduino-IDE

Über dieses Projekt

Über

Hallo, ich möchte meine Arbeit an dem Projekt von nickthegreek82 teilen:arduino-touch-tic-tac-toe-game.

Du brauchst:

  • die Adafruit-Bibliothek
  • die GFX-Bibliothek
  • und die URTouch-Bibliothek

Verkabelung

Die Verkabelung für den Touchscreen ist wie folgt:

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

Für die Anzeige:

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

22.08.2017

Die KI und einige Codeoptimierungen wurden geändert.

26.08.2017

Etwas Code-Optimierung.

27.08.2017

Kann man gegen die CPU gewinnen?

13.03.2018

einen besseren Weg für die KI gefunden

danke geht an klauscam https://github.com/klauscam/ArduinoTicTacToe

Code

  • TIC TAC TOE
  • TicTacToe_neu
TIC TAC TOEArduino
Ein einfaches TIC TAC TOE-Spiel gegen den Computer
 //////////////////////////////////// ///////// // 2.8" TOUCH SCREEN TIC TAC TOE // // // // http://www.educ8s.tv // // // // geändert 08.2017 von rom3 // / ///////////////////////////////////////////#include #include #include #include #include #define TFT_RST 8#define TFT_DC 9#define TFT_CS 10#define TOUCH_ORIENTATION_ILI (TFT_CS, TFT_DC, TFT_RST);Adafruit_GFX_Button-Tasten[9];URTouch myTouch(30, 28, 26, 24, 22);Unsigned Short Int Moves =1; Unsigned Short Int Gewinner =0; //0 =Draw, 1 =Human, 2 =CPUunsigned short int x,y; // position touchunsigned short int Cursor; // Cursor positionunsigned short int firstMoves[]={0,2,6,8}; // verwendet diese Positionen zuerst, wenn CPU beginntunsigned short int board[] ={0,0,0,0,0,0,0,0,0}; // hält Positionsdaten 0 ist leer, 1 Mensch, 2 ist Computerbool-Spieler; // true=YOU, false =CPUbo ol b =1; char start[10] ={"Gamestart"};char you[4] ={"YOU"};char cpu[4] ={"CPU"};char again[7] ={"Again?"}; 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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,0x0,0x0,0x0,0x0,0x0,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); //Weißen Rahmen zeichnen tft.drawRect(0,0,320,240,ILI9341_WHITE); // "Arduino"-Text drucken tft.setCursor(80,30); tft.setTextColor(ILI9341_GREEN); tft.setTextSize(4); tft.print("Arduino"); // "Tic Tac Toe"-Text drucken tft.setCursor (30,100); tft.setTextColor(ILI9341_WHITE); tft.setTextSize(4); tft.print ("Tic Tac Toe"); //Rote Schaltfläche erstellen // Schaltflächen erstellen // x, y, w, h, Umriss, Füllung, Text Schaltflächen[0].initButton(&tft, 160,200,200,40,ILI9341_WHITE, ILI9341_RED, ILI9341_WHITE, start, 2); buttons[0].drawButton();do{ waitonetouch(&x,&y); if (buttons[0].contains(x,y)) b=0;}while(b>0); }void loop() { for(unsigned short int i=0;i<9;i++) { board[i]=0; } tft.fillScreen(ILI9341_BLACK); //Weißen Rahmen zeichnen tft.drawRect(0,0,320,240,ILI9341_WHITE); // "Tic Tac Toe"-Text drucken tft.setCursor(30,30); tft.setTextColor(ILI9341_WHITE); tft.setTextSize(4); tft.print ("Tic Tac Toe"); //Drucke "YouTube!" Text tft.setCursor(30,100); tft.setTextColor(ILI9341_GREEN); tft.setTextSize(4); tft.print("Wer beginnt"); //Rote Schaltfläche erstellen // Schaltflächen erstellen // x, y, w, h, Umriss, Füllung, Text Schaltflächen[0].initButton(&tft, 100,200,80,40,ILI9341_WHITE, ILI9341_RED, ILI9341_WHITE, you, 2); buttons[0].drawButton(); // Schaltflächen erstellen // x, y, w, h, Umriss, Füllung, Text Schaltflächen[1].initButton(&tft, 200,200,80,40,ILI9341_WHITE, ILI9341_RED, ILI9341_WHITE, cpu, 2); buttons[1].drawButton(); b =1; do{ waitonetouch(&x,&y); if (buttons[0].contains(x,y)) { b=0; Spieler =1; tft.fillScreen(ILI9341_BLACK); //Weißen Rahmen zeichnen tft.drawRect(0,0,320,240,ILI9341_WHITE); tft.setCursor(30,30); tft.setTextColor(ILI9341_WHITE); tft.setTextSize(2); tft.print("Ok, Sie beginnen."); Verzögerung (2000); } if(buttons[1].contains(x,y)) {b=0; Spieler =0; tft.fillScreen(ILI9341_BLACK); //Weißen Rahmen zeichnen tft.drawRect(0,0,320,240,ILI9341_WHITE); tft.setCursor(30,30); tft.setTextColor(ILI9341_WHITE); tft.setTextSize(2); tft.print("Ok, CPU beginnt."); Verzögerung (2000); }} while(b>0); b =1; bewegt =1; Gewinner =0; Cursor =10; tft.fillScreen(ILI9341_BLACK); //Rahmen zeichnen tft.drawRect(0,0,320,240,ILI9341_WHITE); //Vertikale Linie zeichnen tft.fillRect(80,15,5,205,ILI9341_WHITE); tft.fillRect(150,15,5,205,ILI9341_WHITE); //Horizontale Linie zeichnen 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 || Moves%2==0 &&player==true) { Cursor+=10; tft.setCursor(240,cursor); tft.setTextSize(1); tft.println("Ich zeichne"); arduinoMove(); checkWinner(); }sonst { Cursor+=10; tft.setCursor(240,cursor); tft.setTextSize(1); tft.println("Ihr Umzug"); SpielerMove(); checkWinner(); } Verzögerung (1000); bewegt ++; }while (Gewinner==0 &&bewegt sich<10); waitonetouch(&x,&y); tft.fillScreen(ILI9341_BLACK); //Rahmen zeichnen tft.drawRect(0,0,320,240,ILI9341_WHITE); // "Game Over"-Text drucken tft.setCursor(50,30); tft.setTextColor(ILI9341_WHITE); tft.setTextSize(4); tft.print("GAME OVER"); if(winner ==0){//Drucke "DRAW!" Text tft.setCursor(110,100); tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(4); tft.print("DRAW");} if(winner ==1){//Print "MENSCH GEWINNT!" Text tft.setCursor(40,100); tft.setTextColor(ILI9341_BLUE); tft.setTextSize(4); tft.print("MENSCH GEWINNT");} if(winner ==2){//Druck "CPU GEWINNT!" Text tft.setCursor(60,100); tft.setTextColor(ILI9341_RED); tft.setTextSize(4); tft.print("CPU WINS");} // Buttons erstellen // x, y, w, h, Outline, Fill, Text buttons[0].initButton(&tft, 160,200,200,40,ILI9341_WHITE, ILI9341_RED, ILI9341_WHITE, nochmal , 2); buttons[0].drawButton(); do{ waitonetouch(&x,&y); if (buttons[0].contains(x,y)) b=0; }während(b>0); }} void playerMove(){ waitonetouch(&x,&y); if((x>15 &&x<85) &&(y>15 &&y<85)) //0 { if(board[0]==0) { board[0]=1; zeichnenX(15,15); } sonst Fehler (); } else if((x>85 &&x<155)&&(y>15 &&y<85)) //1 { if(board[1]==0) { board[1]=1; zeichnenX(85,15); } sonst Fehler (); } if((x>155 &&x<225)&&(y>15 &&y<85)) //2 { if(board[2]==0) { board[2]=1; drawX(155,15); } sonst Fehler (); } if((x>15 &&x<85)&&(y>85 &&y<155)) //3 { if(board[3]==0) { board[3]=1; zeichnenX(15,85); } sonst Fehler (); } if((x>85 &&x<155)&&(y>85 &&y<155)) // { if(board[4]==0) { board[4]=1; zeichnenX(85,85); } sonst Fehler (); } if((x>155 &&x<225)&&(y>85 &&y<155)) //5 { if(board[5]==0) { board[5]=1; zeichnenX(155,85); } sonst Fehler (); } if((x>15 &&x<85)&&(y>155 &&y<225)) //6 { if(board[6]==0) { board[6]=1; drawX(15,155); } sonst Fehler (); } if((x>85 &&x<155)&&(y>155 &&y<225)) // { if(board[7]==0) { board[7]=1; drawX(85,155); } sonst Fehler (); } if((x>155 &&x<225)&&(y>155 &&y<225)) //8 { if(board[8]==0) { board[8]=1; drawX(155,155); } sonst Fehler (); }}Ungültiger Fehler () { Cursor + =10; tft.setCursor(240,cursor); tft.setTextSize(1); tft.println("Fehler"); Verzögerung (1000); Cursor+=10; tft.setCursor(240,cursor); tft.println("Erneut versuchen."); 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) { 0 zurückgeben; } sonst 1 zurückgeben; } if(board[3]==x &&board[6]==x &&board[0]==y){ if(y==0){ return 0; } else return 6; } if(board[0]==y &&board[4]==x &&board[8]==x){ if(y==0){ return 0; } sonst Rückgabe 8; } if(board[0]==x &&board[1]==y &&board[2]==x){ if(y==0){ return 1; } sonst 0 zurückgeben; } if(board[4]==x &&board[7]==x &&board[1]==y){ if(y==0){ return 1; } sonst return 7; } if(board[0]==x &&board[1]==x &&board[2]==y){ if(y==0){ return 2; } sonst 0 zurückgeben; } if(board[5]==x &&board[8]==x &&board[2]==y){ if(y==0){ return 2; } sonst Rückgabe 8; } if(board[4]==x &&board[6]==x &&board[2]==y){ if(y==0){ return 2; } else return 6; } if(board[4]==x &&board[5]==x &&board[3]==y){ if(y==0){ return 3; } else return 5; } if(board[0]==x &&board[6]==x &&board[3]==y){ if(y==0){ return 3; } else return 6; } if(board[3]==x &&board[4]==y &&board[5]==x){ if(y==0){ return 4; } sonst Rückgabe 3; } if(board[1]==x &&board[7]==x &&board[4]==y){ if(y==0){ return 4; } sonst 1 zurückgeben; } if(board[0]==x &&board[8]==x &&board[4]==y){ if(y==0){ return 4; } sonst 0 zurückgeben; } if(board[2]==x &&board[6]==x &&board[4]==y){ if(y==0){ return 4; } sonst Rückgabe 2; } if(board[3]==x &&board[4]==x &&board[5]==y){ if(y==0){ return 5; } sonst Rückgabe 3; } if(board[2]==x &&board[8]==x &&board[5]==y){ if(y==0){ return 5; } sonst Rückgabe 2; } if(board[7]==x &&board[8]==x &&board[6]==y){ if(y==0){ return 6; } sonst Rückgabe 8; } if(board[0]==x &&board[3]==x &&board[6]==y){ if(y==0){ return 6; } sonst 0 zurückgeben; } if(board[4]==x &&board[2]==x &&board[6]==y){ if(y==0){ return 6; } sonst Rückgabe 2; } if(board[1]==x &&board[4]==x &&board[7]==y){ if(y==0){ return 7; } sonst 1 zurückgeben; } if(board[6]==x &&board[8]==x &&board[7]==y){ if(y==0){ return 7; } else return 6; } if(board[6]==x &&board[7]==x &&board[8]==y){ if(y==0){ return 8; } else return 6; } if(board[5]==x &&board[2]==x &&board[8]==y){ if(y==0){ return 8; } sonst Rückgabe 2; } if(board[4]==x &&board[0]==x &&board[8]==y){ if(y==0){ return 8; } sonst 0 zurückgeben; } else Rückgabe 100;}void arduinoMove () { if (moves <2) { do { unsigned short int randomMove =random(4); unsigned short int c=firstMoves[randomMove]; if(board[c]==0){board[c]=2; drawCpuMove(firstMoves[randomMove]); Rückkehr; } } while(bewegt sich <2); } if(bewegt sich<3) { if(board[4]==0) { board[4]=2; drawCpuMove(4); Rückkehr; } } unsigned short int twoPlayer =checkOpponent(2,0); // CPU zwei hintereinander? if(twoPlayer <9) { board[twoPlayer]=2; drawCpuMove(zweiPlayer); Rückkehr; } unsigned short int nextMove =checkOpponent(1,0); //Spieler zwei hintereinander? if(nextMove <9) { board[nextMove]=2; drawCpuMove(nextMove); Rückkehr; } unsigned short int next =checkOpponent(0,2); if(nächste <9) { board[nächste]=2; drawCpuMove(nächste); Rückkehr; } do { unsigned short int randomMove =random(9); if (board[randomMove]==0) { board[randomMove]=2; drawCpuMove (zufällige Bewegung); Rückkehr; } }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); brechen; Fall 1:DrawCircle(85,15); brechen; Fall 2:DrawCircle(155,15); brechen; Fall 3:DrawCircle(15,85); brechen; Fall 4:DrawCircle(85,85); brechen; Fall 5:drawCircle(155,85); brechen; Fall 6:drawCircle(15,155); brechen; Fall 7:drawCircle(85,155);break; Fall 8:drawCircle(155,155);break; }}void checkWinner() // überprüft das Board, um zu sehen, ob es einen Gewinner gibt // Platziert das Ergebnis in der globalen Variablen 'winner'{ // null gewinnt? if (board[0]>0 &&board[1]==board[0] &&board[2]==board[0]) {gewinner=board[0]; tft.fillRect(15, 45, 205, 5, ILI9341_WHITE); } if (board[3]>0 &&board[4]==board[3] &&board[5]==board[3]) {gewinner=board[3]; tft.fillRect(15, 115, 205, 5, ILI9341_WHITE); } if (board[6]>0 &&board[7]==board[6] &&board[8]==board[6]) {gewinner=board[6]; tft.fillRect(15, 185, 205, 5, ILI9341_WHITE); } if (board[0]>0 &&board[3]==board[0] &&board[6]==board[0]) {gewinner=board[0]; tft.fillRect(45, 15, 5, 205, ILI9341_WHITE); } if (board[1]>0 &&board[4]==board[1] &&board[7]==board[1]) {gewinner=board[1]; tft.fillRect(115, 15, 5, 205, ILI9341_WHITE); } if (board[2]>0 &&board[5]==board[2] &&board[8]==board[2]) {gewinner=board[2]; tft.fillRect(185, 15, 5, 205, ILI9341_WHITE); } if (board[0]>0 &&board[4]==board[0] &&board[8]==board[0]) {gewinner=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]) {gewinner=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 =myTouch.getX(); //Berührungspunkt abrufen *y =myTouch.getY(); Rückkehr; } } while(myTouch.dataAvailable()==false); }
TicTacToe_newArduino
Ein unbesiegbarer Tic Tac Toe-Einzelspieler auf Arduino Due
 ///////////////////////////////////// //////// // 2.8" TOUCH SCREEN TIC TAC TOE // // // // http://www.educ8s.tv // // // // geändert 08.2017 von rom3 // // //////////////////////////////////////////#include  #include #include #include #define TFT_RST 8#define TFT_DC 9#define TFT_CS 10#define TOUCH_ORIENTATION LANDSCADA [9];URTouch myTouch(30, 28, 26, 24, 22);char start[10] ={"Gamestart"};char you[4] ={"YOU"};char cpu[4] ={" CPU"};char again[7] ={"Again?"};int player;int schwierigkeit=8;unsigned short int x,y,b; // position touch#define BLACK 0x0000#define BLUE 0x001F#define RED 0xF800 #define GREEN 0x07E0#define CYAN 0x07FF#define MAGENTA 0xF81F#define YELLOW 0xFFE0#define WHITE 0xFFFFint board[]={0,0,0,0,0,0,0,0,0};// hält Positionsdaten 0 ist leer, 1 Mensch, 2 ist am Computer nicht signiert;c onst 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,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0x0,0x0,0x0,0x0,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);}void loop(){ int board[9] ={0,0,0,0,0,0,0,0,0,0}; drawStartScreen(); do{myTouch.read(); x =myTouch.getX(); //Berührungspunkt holen y =myTouch.getY(); Verzögerung (100); }while(!(buttons[0].contains(x,y))); tft.fillScreen (SCHWARZ); // Weißen Rahmen zeichnen tft.drawRect(0,0,320,240,WHITE); // "Tic Tac Toe"-Text drucken tft.setCursor(30,30); tft.setTextColor(WEISS); tft.setTextSize(4); tft.print ("Tic Tac Toe"); //Drucke "YouTube!" Text tft.setCursor(30,100); tft.setTextColor(GRÜN); tft.setTextSize(4); tft.print("Wer beginnt"); //Rote Schaltfläche erstellen // Schaltflächen erstellen // x, y, w, h, Umriss, Füllung, Text Schaltflächen[0].initButton(&tft, 100,200,80,40,WHITE, RED, WHITE, you, 2); buttons[0].drawButton(); // Schaltflächen erstellen // x, y, w, h, Umriss, Füllung, Text Schaltflächen[1].initButton(&tft, 200,200,80,40,WHITE, RED, WHITE, cpu, 2); buttons[1].drawButton(); b =1; do{myTouch.read(); x =myTouch.getX(); //Berührungspunkt holen y =myTouch.getY(); if (buttons[0].contains(x,y)) { b=0; Spieler =1; tft.fillScreen (SCHWARZ); // Weißen Rahmen zeichnen tft.drawRect(0,0,320,240,WHITE); tft.setCursor(30,30); tft.setTextColor(WEISS); tft.setTextSize(2); tft.print("Ok, Sie beginnen."); Verzögerung (2000); } if(buttons[1].contains(x,y)) {b=0; Spieler =2; tft.fillScreen (SCHWARZ); // Weißen Rahmen zeichnen tft.drawRect(0,0,320,240,WHITE); tft.setCursor(30,30); tft.setTextColor(WEISS); tft.setTextSize(2); tft.print("Ok, CPU beginnt."); Verzögerung (2000); } }während(b); tft.fillScreen (SCHWARZ); tft.drawRect(0,0,319,240,WEISS); drawVerticalLine(125); drawVerticalLine(195); DrawHorizontalLine(80); DrawHorizontalLine(150); for(turn =0; turn <9 &&win(board) ==0; ++turn) { if((turn+player) % 2 ==0) computerMove(board); else {//zeichnen (Brett); SpielerMove(Brett); } } switch (win (board)) { case 0:Serial.println ( "Es ist ein Unentschieden. \ n"); brechen; Fall 1:// zeichnen (Brett); Serial.println("Du verlierst.\n"); brechen; Fall -1:Serial.println("Sie gewinnen!\n"); brechen; } 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,WHITE); }}void drawVerticalLine(int x){int i=0; for(i=0;i<7;i++) { tft.drawLine(x+i,20,x+i,220,WHITE); }} DrawStartScreen () { tft.fillScreen (BLACK); // Weißen Rahmen zeichnen tft.drawRect(0,0,319,240,WHITE); // "Tic Tac Toe"-Text drucken tft.setCursor (30,100); tft.setTextColor(WEISS); tft.setTextSize(4); tft.print ("Tic Tac Toe"); //Drucke "YouTube!" Text tft.setCursor(80,30); tft.setTextColor(GRÜN); tft.setTextSize(4); tft.print("Arduino"); buttons[0].initButton(&tft, 160,200,200,40,WEISS, ROT, WEISS, start, 2); buttons[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 Byte; for(j=0; j score) { score =tempScore; bewegen =ich; } } } // Gibt eine Punktzahl basierend auf dem Minimax-Baum an einem bestimmten Knoten zurück. Brett[bewegen] =1; drawCpuMove(verschieben); delay(100);}void playerMove(int board[9]) {int move =0; b =1; do { if (myTouch.dataAvailable() ==true) { myTouch.read(); x =myTouch.getX(); //Berührungspunkt holen 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)) // { 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)) // { 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); Brett[bewegen] =-1; drawPlayerMove(move); delay(100);}int win(const int board[9]) { //Liste der möglichen Gewinnpositionen 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 deep) { //Überprüfe die Positionen der Spieler int winner =win(board); if(winner !=0) Rückgabe Gewinner*Spieler; int move =-1; int-Wert =-2; int ich; for(i =0; i <9; ++i) { if(board[i] ==0) { board[i] =Spieler; int thisScore=0; if (Tiefe score) { score =thisScore; bewegen =ich; } //Wähle den schlechtesten Zug für das gegnerische Board[i] =0; } } if(move ==-1) Rückgabe 0; Ergebnis zurückgeben;}void drawCpuMove (int move) { switch (move) { Fall 0:drawCircle (55,15); brechen; Fall 1:DrawCircle(130,15); brechen; Fall 2:DrawCircle(205,15); brechen; Fall 3:DrawCircle(55,85); brechen; Fall 4:DrawCircle(130,85); brechen; Fall 5:drawCircle(205,85); brechen; Fall 6:drawCircle(55,155); brechen; Fall 7:drawCircle(130,155);break; Fall 8:drawCircle(205,155);break; }}void drawPlayerMove(int move){ switch(move) { case 0:drawX(55,15); brechen; Fall 1:drawX(130,15); brechen; Fall 2:drawX(205,15); brechen; Fall 3:drawX(55,85); brechen; Fall 4:drawX(130,85); brechen; Fall 5:drawX(205,85); brechen; Fall 6:drawX(55,155); brechen; Fall 7:drawX(130,155);break; Fall 8:drawX(205,155);break; }}

Schaltpläne

Verdrahtung

Herstellungsprozess

  1. Visitenkarte des Tic-Tac-Toe-Spiels
  2. CO2-Überwachung mit K30-Sensor
  3. taubblinde Kommunikation mit 1Sheeld/Arduino
  4. Münzprüfer mit Arduino steuern
  5. Arduino mit Bluetooth zur Steuerung einer LED!
  6. Kapazitiver Fingerabdrucksensor mit einem Arduino oder ESP8266
  7. Mit Nextion Display spielen
  8. Nunchuk-gesteuerter Roboterarm (mit Arduino)
  9. Messung der Sonneneinstrahlung mit Arduino
  10. Mini-Radar mit Arduino