Tech-TicTacToe
コンポーネントと消耗品
> |
| × | 1 | |||
| × | 1 | ||||
| × | 1 |
必要なツールとマシン
> |
|
アプリとオンラインサービス
> |
|
このプロジェクトについて
こんにちはハックスターコミュニティ。
私はSimoneAdobsです。これは、Hacksterでリリースした3番目のプロジェクトです。これは、段ボール、紙、ホットグルーガンを使用して、Arduinoやその他のコンポーネントを含む構造を作成する最初のプロジェクトです。
これは、Trisがどのように機能するかを示す短いビデオです:
ここでは、すべてのビューからプロジェクトを見ることができます:
私はそれに数時間を費やしたので、あなたがそれを好きになることを願っています!それでは、プロジェクトから始めましょう。
Trisはどのように機能しますか?
答えは非常に簡単です。キーパッドの数字をクリックすると、Arduinoは対応する正方形をオンにします。
- プレーヤーを切り替えることはできますか?
正方形をオンにすると、Arduinoは即座に次のプレーヤーのターンに切り替わります。
- Arduinoは私が勝ったときに認識しますか?
プレーヤーが勝つと、ArduinoはLEDドットマトリックスに書き込みます:
- 勝者がプレーヤー1の場合は「1」;
- 勝者がプレーヤー2の場合は「2」。
ゲームが終了したら、ボタンからArduinoを再起動できますか?
キーパッドの「0」ボタンをクリックすると、ゲームを再開できます。Arduinoが自動的に再開します。
プレーヤーを認識するにはどうすればよいですか?
LEDドットマトリックスは赤のみですが、すべてのプレーヤーには2x2 LEDによって形成される特定のパターンがあるため、プレーヤーを簡単に認識できます。
- プレーヤー1のパターンは次のとおりです: "\"
- プレーヤー2には次のパターンがあります: "/"
質問、提案、批判、またはコードの説明については、以下にコメントしてください。このプロジェクトが気に入ったら、いいねを残して、他のプロジェクトを見てください!
別の構造を作成するか、構造をパーソナライズして、その写真を送ってください!
良い一日を!
イタリアのシモーネ<3
コード
- Tech-Tris
Tech-Tris C / C ++
#include#include #include #include #define Reset_AVR()wdt_enable(WDTO_30MS); while(1){} LedControl lc =LedControl(12,10,11,1); bool player1 =true、q1 =false、q2 =false、q3 =false、q4 =false、q5 =false、q6 =false、q7 =false、q8 =false、q9 =false; int row、col、rowPlays、colPlays、result、player、winner; char hexaKeys [4] [3] ={{'1'、 '2'、 '3'}、 {'4'、 '5'、 '6'}、{'7'、 '8'、 '9'}、{'*'、 '0'、 '#'}}; int Plays [3] [3 ] ={{0,0,0}、{0,0,0}、{0,0,0}}; byte rowPins [4] ={8、7、6、5}; byte colPins [3] ={4、3、2}; Keypad customKeypad =Keypad(makeKeymap(hexaKeys)、rowPins、colPins、4、3); void setup(){lc.shutdown(0、false); lc.setIntensity(0,0); lc.clearDisplay(0);} void loop(){int customKey =customKeypad.getKey();絵画(customKey); win(結果); if(winner ==1){lc.clearDisplay(0); while(winner ==1){char customKey =customKeypad.getKey(); if(customKey =='0'){Reset_AVR(); } lc.setLed(0,1,4、true); lc.setLed(0,2,5、true); lc.setLed(0,3,6、true); lc.setLed(0,4,7、true); lc.setLed(0,4,6、true); lc.setLed(0,4,5、true); lc.setLed(0,4,4、true); lc.setLed(0,4,3、true); lc.setLed(0,4,2、true); lc.setLed(0,4,1、true); lc.setLed(0,4,0、true); lc.setLed(0,5,0、true); lc.setLed(0,6,0、true); lc.setLed(0,3,0、true); lc.setLed(0,2,0、true); }} else if(winner ==2){lc.clearDisplay(0); while(winner ==2){char customKey =customKeypad.getKey(); if(customKey =='0'){Reset_AVR(); } lc.setLed(0,2,0、true); lc.setLed(0,3,0、true); lc.setLed(0,4,0、true); lc.setLed(0,5,0、true); lc.setLed(0,2,1、true); lc.setLed(0,2,2、true); lc.setLed(0,2,3、true); lc.setLed(0,2,4、true); lc.setLed(0,3,4、true); lc.setLed(0,4,4、true); lc.setLed(0,5,4、true); lc.setLed(0,5,5、true); lc.setLed(0,5,6、true); lc.setLed(0,5,7、true); lc.setLed(0,4,7、true); lc.setLed(0,3,7、true); lc.setLed(0,2,7、true); }}} int round_player(){if(player1){player1 =false;結果=1; } else {player1 =true;結果=2; } return result;} void win(int player){if(plays [0] [0] ==player &&playing [0] [1] ==player &&playing [0] [2] ==player){winner =プレーヤー; } else if(plays [1] [0] ==player &&playing [1] [1] ==player &&playing [1] [2] ==player){winner =player; } else if(plays [2] [0] ==player &&playing [2] [1] ==player &&playing [2] [2] ==player){winner =player; } else if(plays [0] [0] ==player &&playing [1] [0] ==player &&playing [2] [0] ==player){winner =player; } else if(plays [0] [1] ==player &&playing [1] [1] ==player &&playing [2] [1] ==player){winner =player; } else if(plays [0] [2] ==player &&playing [1] [2] ==player &&playing [2] [2] ==player){winner =player; } else if(plays [0] [0] ==player &&playing [1] [1] ==player &&playing [2] [2] ==player){winner =player; } else if(plays [0] [2] ==player &&playing [1] [1] ==player &&playing [2] [0] ==player){winner =player; }} void switch_on_led(int col、int row、int colPlays、int rowPlays){if(player1){lc.setLed(0、col、row、true); lc.setLed(0、col + 1、row-1、true); } else {lc.setLed(0、col、row-1、true); lc.setLed(0、col + 1、row、true); } Plays [rowPlays] [colPlays] =round_player();} void Painting(int bottone){switch(bottone){case 49:if(!q1){switch_on_led(0,7,0,0); q1 =true; } 壊す;ケース50:if(!q2){switch_on_led(3,7,0,1); q2 =true; } 壊す;ケース51:if(!q3){switch_on_led(6,7,0,2); q3 =true; } 壊す;ケース52:if(!q4){switch_on_led(0,4,1,0); q4 =true; } 壊す;ケース53:if(!q5){switch_on_led(3,4,1,1); q5 =true; } 壊す;ケース54:if(!q6){switch_on_led(6,4,1,2); q6 =true; } 壊す;ケース55:if(!q7){switch_on_led(0,1,2,0); q7 =true; } 壊す;ケース56:if(!q8){switch_on_led(3,1,2,1); q8 =true; } 壊す;ケース57:if(!q9){switch_on_led(6,1,2,2); q9 =true; } 壊す;ケース48:Reset_AVR();壊す; }}
回路図
tris_1Nd6QnEjNE.fzz 製造プロセス