This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void beep(String letter){ | |
| //Beeps letter | |
| for (int index = 0; index < letter.length(); index++){ | |
| //Figures out if char is dot or dash and turns it on and off with varying delay. | |
| switch (letter[index]) { | |
| case '.': | |
| digitalWrite(13, HIGH); | |
| delay(100); | |
| digitalWrite(13, LOW); | |
| break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define compareBoxes(box1, box2, box3) ((board[box1] == board[box2]) && (board[box2] == board[box3]) && (board[box1] != 0)) //Checkes if three items are the same, and makes sure they're not 0's. | |
| #define numberToLetter(x) ((x > 0) ? (x == 1) ? 'X' : 'O' : ' ') //Takes the number and turns it into the letter or space. | |
| int getWinner(int board[9]) { | |
| //Finds winner of game, if there is no winner, returns 0. | |
| int winner = 0; | |
| for (int x = 0; x < 3; x++) { | |
| if (compareBoxes(3*x, 3*x+1, 3*x+2)) { //Chekcs rows. | |
| winner = board[3*x]; | |
| break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <cstring> | |
| #include <algorithm> | |
| #include <ctime> | |
| using namespace std; | |
| #define compareBoxes(box1, box2, box3) ((board[box1] == board[box2]) && (board[box2] == board[box3]) && (board[box1] != 0)) //Checkes if three items are the same, and makes sure they're not 0's. | |
| #define numberToLetter(x) ((x > 0) ? (x == 1) ? 'X' : 'O' : ' ') //Takes the number and turns it into the letter or space. |