Tic Tac Yo!

by rremala in Circuits > Arduino

332 Views, 0 Favorites, 0 Comments

Tic Tac Yo!

IMG_1008.JPG

tic tac yo is an interactive lamp through which you can play the gam of tic-tac-toe with your loved ones even if they are far away.

The idea behind it is to show appreciation and love by acknowledging and reciprocating your presence and taking out 0.10 seconds of your life to play the tic tac toe game.

The Product comes with 2 lamps - one for you and the other for your loved one! The lamp is to be placed in a busy environment of your life and it glows whenever one of the lamp owners plays a move.

Supplies

IMG_1029.JPG
  1. Wood - any soft wood
  2. Neopixel strip lights 60 LEDs - white
  3. Arduino wifi board
  4. Stacking headers
  5. Wood glue
  6. Dowel - 3/8"
  7. Resistive touch screen*
  8. Silicone tubing flat
  9. Adafruit Huzzah Feather or ESP8266 Huzzah breakout board (with FTDI cable & lipoly charging board)

Video

MVI 1021

Here is a short video about Tic tac yo

Form and Build

0bae97d3-a3b6-4f8a-8c05-c32724864656.jpg
WhatsApp Image 2022-12-07 at 9.30.18 AM (1).jpeg
WhatsApp Image 2022-12-07 at 9.30.18 AM.jpeg
WhatsApp Image 2022-12-07 at 9.30.19 AM (1).jpeg
WhatsApp Image 2022-12-07 at 9.30.19 AM.jpeg
4Asset 2@4x-8.png
4Asset 1@4x-8.png

Here is a sketches of the how the form of the product will look and each part that goes into the product individually.


For the build the process of making the form will be woodshop driven. I am prototyping the initial trial cuts with blue foam and soft wood using the band saw and table saw.

Then going in with repeating the same process with any soft wood.

Once the basic shapes are cut out we will use the router table to make the even indentations on the edges where the light will reside.

For the cross sectional body it is going to be 2 pieces of wood which will be glued together for making the internal structure.

Once the pieces are cut, you will need a dowel, wood glue and drilling machine to connect all joints.

Once the light and circuit is placed inside the form it will be sealed with the flat silicone tubing.




Circuit and Code

f3f9920d-8617-4fab-88cc-d2f764a35f95.jpg

The circuit we are using is very similar to the internet valentine project except the interface is now a touch screen*

but we need to interact two ways so the code and button set up changes.


The code is the tic tac toe game code which is embedded into a the circuit.


#include <ESP8266WiFi.h>
#include <AdafruitIO.h>
#include <Adafruit_MQTT.h>
#include <ArduinoHttpClient.h>

#define IO_USERNAME    "samasrinivas"
#define IO_KEY         "aio_XzUr94DA4HXGiqXKUKPoh5WojS6i"

#define WIFI_SSID       "Internet Of Things Class"
#define WIFI_PASS       "iheartarduino"
#include "AdafruitIO_WiFi.h"
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);

#include <Adafruit_NeoPixel.h>
#define PIXELS_PIN 15
#define NUM_LEDS 100
#define BRIGHTNESS 20

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIXELS_PIN, NEO_GRBW + NEO_KHZ800);


// Variables
int tictac[10];
boolean s2_flag, s3_flag , s4_flag , s5_flag , s6_flag , s7_flag , s8_flag , s9_flag , s10_flag, winner_flag ;
int s2, s3, s4, s5, s6, s7, s8, s9, s10;
int p2, p3, p4, p5, p6, p7, p8, p9, p10;
int i2, i3, i4, i5, i6, i7, i8, i9, i10;
int count = 0 ;
String winner;
int P1_points = 0 , P2_points = 0 ;
char sx, control ;
int played = 0;
int press = NULL;


#define BUTTON_PIN 4
#define LED_PIN 13
#define ROWS 3
#define COLUMNS 3
//#define RESET_PIN 12
#define RED strip.setPixelColor(i, strip.Color(255, 0, 0));
#define GREEN strip.setPixelColor(i, strip.Color(0, 255, 0));
#define IO_USERNAME "rohremala"
#define IO_KEY "aio_Odav85HUSnTILVtRy4VBsieK4S9V"

/******************************* WIFI Configuration **************************************/

#define WIFI_SSID "Internet of Things Class"
#define WIFI_PASS "iheartadruino"

#include "AdafruitIO_WiFi.h"
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);


// Pin Definition

// GREEN LED
int P1[ROWS][COLUMNS] =
{
14 , 16 , 18 ,
20 , 22 , 24,
26 , 28 , 30
};


//RED LED
int Internet_Data[ROWS][COLUMNS] =
{
i2, i3 , i4 ,
i5, i6 , i7,
i8 , i9 , i10
};

void setup()
{
Serial.print("Connecting to Adafruit IO");
io.connect();
lampMode();
digitalWrite(RESET_PIN, HIGH);
pinMode(RESET_PIN, OUTPUT);

s2_flag = s3_flag = s4_flag = s5_flag = s6_flag = s7_flag = s8_flag = s9_flag = s10_flag = winner_flag = false ;

for (int i = 0 ; i < 9 ; i++) //clearing the array on reset
tictac[i] = 0 ;

Serial.begin(115200);

pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
pinMode(8, INPUT);
pinMode(9, INPUT);
pinMode(10, INPUT);
pinMode(buzzer, OUTPUT);

// defining all LED pins as output
for (int i = 0; i < 3 ; i++)
{
for (int j = 0; j < 3; j++)
{
pinMode(P1[i][j], OUTPUT);
pinMode(Internet_data[i][j], OUTPUT);

}
}


}

void loop()
{
strip.show();
//set press value to what is read from button
p2 = !digitalRead(2) *7 ;
p3 = !digitalRead(3) *8 ;
p4 = !digitalRead(4) *9 ;
p5 = !digitalRead(5) *10;
p6 = !digitalRead(6) *11;
p7 = !digitalRead(7) *12;
p8 = !digitalRead(8) *13;
p9 = !digitalRead(9) *14;
p10 = !digitalRead(10) *15;

int temp =
press = digital.write();
if(count > 0){
livePlayer(press, played)


//Reading status from internet
if(played == 1){
i2 = !internetRead(2) ;
i3 = !internetRead(3) ;
i4 = !internetRead(4) ;
i5 = !internetRead(5) ;
i6 = !internetRead(6) ;
i7 = !internetRead(7) ;
i8 = !internetRead(8) ;
i9 = !internetRead(9) ;
i10 = !internetRead(10) ;


// interet move logger

if (i2 == HIGH && s2_flag == false )
{
pinMode(P1[0][0],RED)
s2_flag = true ;
count ++;
tictac[0] = 1;
}

else if (s3 == HIGH && s3_flag == false )
{
pinMode(P1[0][1],RED)
s3_flag = true ;
count ++;
tictac[1] = 1;
}

else if (s4 == HIGH && s4_flag == false )
{
pinMode(P1[0][2],RED)
s4_flag = true ;
count ++;
tictac[2] = 1;
}

else if (s5 == HIGH && s5_flag == false )
{
pinMode(P1[1][0],RED)
s5_flag = true ;
count ++;
tictac[3] = 1;
}

else if (s6 == HIGH && s6_flag == false )
{
pinMode(P1[1][1],RED)
s6_flag = true ;
count ++;
tictac[4] = 1;
}

else if (s7 == HIGH && s7_flag == false )
{
pinMode(P1[1][2],RED)
s7_flag = true ;
count ++;
tictac[5] = 1;
}

else if (s8 == HIGH && s8_flag == false )
{
pinMode(P1[2][0],RED)
s8_flag = true ;
count ++;
tictac[6] = 1;
}

else if (s9 == HIGH && s9_flag == false )
{
pinMode(P1[2][1]],RED)
s9_flag = true ;
count ++;
tictac[7] = 1;
}

else if (s10 == HIGH && s10_flag == false )
{
pinMode(P1[2][2],RED)
s10_flag = true ;
count ++;
tictac[8] = 1;
}
}


winner = check(); // Checking if anyone won the match


if(winner == "P")
serial.println("Player 1 wins");
else if(winner == "I")
serial.println("Player 2 wins");
// --------------------------------------------- It's a DRAW match
else if (winner == "0" && count == 9 )
{
Serial.println(" Draw match !! ") ;
winner_flag = true ;
for (int k = 0 ; k < 7 ; k++)
{
for (int i = 0; i < 3 ; i++)
{
for (int j = 0; j < 3; j++)
{
digitalWrite(G[i][j], HIGH);
digitalWrite(R[i][j], HIGH);

}
}
beep();
for (int i = 0; i < 3 ; i++)
{
for (int j = 0; j < 3; j++)
{
digitalWrite(G[i][j], LOW);
digitalWrite(R[i][j], LOW);

}
}
beep();
}
Serial.println("resetting..");
resett();
}

if (winner_flag == true )
{ Serial.println("resetting..");
resett();
}

}

// Checking if anyone won the match
String check ()
{

// --------------------------------------------- RED WINS
if ( (tictac[0] + tictac[1] + tictac[2]) == 3 )
{
return "I";
}
if ((tictac[3] + tictac[4] + tictac[5]) == 3 )
{
return "I";
}
if ((tictac[6] + tictac[7] + tictac[8]) == 3 )
{
return "I";
}
if ((tictac[0] + tictac[3] + tictac[6]) == 3 )
{
return "I";
}
if ((tictac[1] + tictac[4] + tictac[7]) == 3 )
{
return "I";
}
if ((tictac[2] + tictac[5] + tictac[8]) == 3 )
{
return "I";
}
if ((tictac[0] + tictac[4] + tictac[8]) == 3 )
{
return "I";
}
if ((tictac[2] + tictac[4] + tictac[6]) == 3 )
{
return "I";
}


// --------------------------------------------- GREEN WINS

if ((tictac[0] + tictac[1] + tictac[2]) == 6 )
{
return "P";
}

if ((tictac[3] + tictac[4] + tictac[5]) == 6 )
{
return "P";
}
if ((tictac[6] + tictac[7] + tictac[8]) == 6 )
{
return "P";
}
if ((tictac[0] + tictac[3] + tictac[6]) == 6 )
{
return "P";
}
if ((tictac[1] + tictac[4] + tictac[7]) == 6 )
{
return "P";
}
if ((tictac[2] + tictac[5] + tictac[8]) == 6 )
{
return "P";
}
if ((tictac[0] + tictac[4] + tictac[8]) == 6 )
{
return "P";
}
if ((tictac[2] + tictac[4] + tictac[6]) == 6 )
{
return "P";
}


// --------------------------------------------- No one WON Yet
else
return "0" ;
}
}

// --------------------------------------------- Resetting the Board after the Games gets over
void resett()
{

digitalWrite(RESET_PIN,LOW);
lampMode();

}

int liveplayer (int press, int played){
if(count <=10){
if(P1[0][0] % press == 2 && s2_flag == false)
{
pinMode(P1[0][0],GREEN)
s2_flag = true ;
count ++;
tictac[0] = 2;
return "1";
}
if(P1[0][1] % press == 2 && s3_flag == false)
{
pinMode(P1[0][1],GREEN)
s3_flag = true ;
count ++;
tictac[1] = 2;
return "1";
}
if(P1[0][2] % press == 2 && s4_flag == false)
{
pinMode(P1[0][2],GREEN)
s4_flag = true ;
count ++;
tictac[2] = 2;
return "1";
}
if(P1[1][0] % press == 2 && s5_flag == false)
{
pinMode(P1[1][0],GREEN)
s5_flag = true ;
count ++;
tictac[3] = 2;
return "1";
}
if(P1[1][1] % press == 2 && s6_flag == false)
{
pinMode(P1[1][1],GREEN)
s6_flag = true ;
count ++;
tictac[4] = 2;
return "1";
}
if(P1[1][2] % press == 2 && s7_flag == false)
{
pinMode(P1[1][2],GREEN)
s7_flag = true ;
count ++;
tictac[5] = 2;
return "1";
}
if(P1[2][0] % press == 2 && s8_flag == false)
{
pinMode(P1[2][0],GREEN)
s8_flag = true ;
count ++;
tictac[6] = 2;
return "1";
}
if(P1[2][1] % press == 2 && s9_flag == false)
{
pinMode(P1[2][1],GREEN)
s9_flag = true ;
count ++;
tictac[7] = 2;
return "1";
}
if(P1[2][2] % press == 2 && s10_flag == false)
{
pinMode(P1[2][2],GREEN)
s10_flag = true ;
count ++;
tictac[8] = 2;
return "1";
}
else
return"0";
}
int data = index(tictac[]);
int command = data->toInt();

}

void lampMode(){
strip.setPixelColor(255,255,255);
  for (int fadeValue = 0; fadeValue <= 255; fadeValue += 5) {
    for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
      strip.setPixelColor(i, strip.Color(0,0,0,255));         //  Set pixel's color (in RAM)
    }
    strip.setBrightness(fadeValue);
    strip.show();                          //  Update strip to match
    delay(1000);
  }
 //if you want it to turn off, here is the place
   for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
     strip.setPixelColor(i, strip.Color(0,0,0,0));         //  Set pixel's color (in RAM)
   }
   strip.show();
}


Some More Images

IMG_1024.JPG
IMG_1026.JPG
week3-1Asset 3@4x-8.png
week3-1Asset 4@4x-8.png