Tic Tac Yo

Our families may be in close proximity or far away, but even on the laziest days we don’t interact and take time out to be with them. So here is tic-tac-yo! – an interactive lamp which lets you play tic-tac-toe with the people you love. 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.

Instructables Link :- https://www.instructables.com/Tic-Tac-Yo/

Tic-tac-Yo! Manufacturing Materials 

  1. Wood – any soft wood
  2. Neopixel strip lights 60 LEDs – white
  3. Arduino wifi board
  4. Stacking headers
  5. Wood glue
  6. wire cutter
  7. wire stripper
  8. soldering iron set
  9. drilling machinge – 1/4′ inch and 1/8″ drill bits
  10. Adafruit Huzzah Feather or ESP8266 Huzzah breakout board (with FTDI cable & lipoly charging board)

Building

here is the like to the circuit, form and build blueprint.

For the actual build we went into the woodshop and used the table saw, minor saw, and band saw for cutting the basic shape of the product and then used sanding tools and drilling machine to finish the product

Here are some process images and videos:

Code

the code is determined by dismantling the tic tac toe game its different possibilities

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


// 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); 
  strip.show();  
}

Order Now!

%d