Introduction: Nike Restock Light

I was given the assignment of creating an object that utilizes an Arduino Uno. From there I developed the idea of creating a small mood light that responds to a key phrase that is tweeted out by specific Twitter account. The purpose of this light would be to alert me of the very rare restocks that Nike does on occasion.

With the resale market of sneakers becoming a 1 billion dollar industry people will use any advantage they can get in order to purchase as many pairs of the rare Nikes that are released. I am not in the business of reselling sneakers but I want to avoid having to pay over retail in order to get a pair of sneakers that I really want.

Since the light will only be turned on for very rare occasions I spent majority of my time on the aesthetics of the light. I figured that it should be something that while it may not be on the majority of the time should still be pleasing to look at.

Step 1: Collecting Materials

I used quite a few materials for this project, some of them may not be necessary and obviously you could change the way the light looks and perhaps use fewer materials.

Electronic Materials

  • Arduino Uno R3 (I purchased a SainSmart version in an effort to cut costs)
  • Arduino Ethernet Shield (I purchased mine from Radio Shack for only $10)
  • 4 Leds
  • Ethernet cord
  • Power supply adapter
  • Solder

Aesthetic Materials

  • Acrylic Box (I was able to find one pre-made in the storage section of Walmart)
  • Small amount of wood roughly 1/2 inch thick (can be changed in order to slim down the look of the light)
  • Rubber feet
  • Wood stain
  • Frosted glass spray paint
  • Foam (used to house the Arduino)
  • Sheet of vinyl (used to make a stencil to paint on the acrylic)
  • Nails
  • Wood glue

Tools needed

  • Soldering iron
  • Drill
  • Nail gun
  • Hot glue gun
  • Die-cutting plotter (used for the stencil, not necessary)

Step 2: Constructing the Electronics

With a limited knowledge of electronics I tried to keep everything as simple as possible. I simply soldered the leds directly to the ethernet shield since it was inexpensive. I used ports 12 and 13 for the leds. Then I simply snapped the ethernet shield into place on the Arduino.

Step 3: Wood Housing Unit

I constructed a housing unit made of wood that the acrylic box would sit inside of. After I constructed the shape I drilled a hole through one side of it so that the ethernet cord and power supply cord can be ran out of the light and be plugged in.

After I gave the wood a light sanding I applied a dark wood stain to it.

Once the stain completely dried I applied the small rubber feet to each corner of the box.

Step 4: Acrylic Box

I was lucky enough to find a clear acrylic box pre-made but you could just as easily build your own. I also drilled a hole into the box that corresponds with the hole in the wood so that the cords can easily be plugged into the light.

After drilling the hole I applied one coat of the frosted glass spray paint. I suggest wiping down the acrylic prior to painting it so that you avoid any imperfections in the frosted paint. After the first coat completely dried I used my plotter to cut out a Nike logo along with the word restock on a piece of vinyl. I applied the vinyl to the acrylic box and then sprayed three more coats of the frosted glass spray to it. After a few minutes of drying I carefully peeled off the vinyl. The stencil should have left just a minor difference in the frosted pain, in fact you may not be able to see the graphic at all from certain angles.

Once a light is emitted inside of box the graphic will be visible. The photo shown is an example of what it should look like after a light is emitted.

Step 5: Foam Housing

I took a small thin sheet of foam and pressed the opening of the acrylic box into the foam. That left a impression in the foam which I then cut out. From there I traced out the Arduino on the foam and then shaved the foam down so that there was a small inlay for the Arduino to sit inside of.

Step 6: Arduino Coding

Here is the code for the Nike Restock alert. there are several things you must do in order for it to work; you must change the ip address and the mac address.

<p>/*<br>  Twitter Client with Strings
 
 This sketch connects to Twitter using an Ethernet shield. It parses the XML
 returned, and looks for this is a tweet
 
 You can use the Arduino Ethernet shield, or the Adafruit Ethernet shield, 
 either one will work, as long as it's got a Wiznet Ethernet module on board.
 
 This example uses the DHCP routines in the Ethernet library which is part of the 
 Arduino core from version 1.0 beta 1
 
 This example uses the String library, which is part of the Arduino core from
 version 0019.  
 
 Circuit:
  * Ethernet shield attached to pins 10, 11, 12, 13
 
 created 21 May 2011
 by Tom Igoe
 modified by Amanda Ghassaei June 2012
 https://www.instructables.com/id/Twitter-Controlled-Pet-Feeder/
 
 modified again by cdw181818 December 2014
 
 This code is in the public domain.
 
 */
#include 
#include </p><p>//variable to prevent overfeeding
boolean nikeRestock = 1;</p><p>// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
IPAddress ip(xxx,xxx,xxx,xx; //<<< ENTER YOUR IP ADDRESS HERE</p><p>// initialize the library instance:
EthernetClient client;</p><p>const int requestInterval = 60000;  // delay between requests = 1min</p><p>char serverName[] = "api.twitter.com";  // twitter URL</p><p>boolean requested;                   // whether you've made a request since connecting
long lastAttemptTime = 0;            // last time you connected to the server, in milliseconds</p><p>String currentLine = "";            // string to hold the text from server
String tweet = "";                  // string to hold the tweet
boolean readingTweet = false;       // if you're currently reading the tweet</p><p>void setup() {
  
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  
  // reserve space for the strings:
  currentLine.reserve(256);
  tweet.reserve(150);</p><p>// initialize serial:
  Serial.begin(9600);
  // attempt a DHCP connection:
  if (!Ethernet.begin(mac)) {
    // if DHCP fails, start with a hard-coded address:
    Ethernet.begin(mac, ip);
  }
  // connect to Twitter:
  connectToServer();
  
  testing();
}</p><p>void loop()
{
  if (nikeRestock){
    if (client.connected()) {
      if (client.available()) {
        // read incoming bytes:
        char inChar = client.read();</p><p>        // add incoming byte to end of line:
        currentLine += inChar; 
  
        // if you get a newline, clear the line:
        if (inChar == '\n') {
          currentLine = "";
        } 
        // if the current line ends with , it will
        // be followed by the tweet:
        if ( currentLine.endsWith("")) {
          // tweet is beginning. Clear the tweet string:
          readingTweet = true; 
          tweet = "";
        }
        // if you're currently reading the bytes of a tweet,
        // add them to the tweet String:
        if (readingTweet) {
          if (inChar != '<') {
            tweet += inChar;
          } 
          else {
            // if you got a "<" character,
            // you've reached the end of the tweet:
            readingTweet = false;
            Serial.println(tweet);
            
            if(tweet == ">restock"){
             digitalWrite(12, HIGH);
             digitalWrite(13, HIGH);
             Serial.println("LED ON!");
             delay(360000);//turn on for 1 hour
             digitalWrite(12, LOW);
             digitalWrite(13, LOW);
             nikeRestock = 0;
            }
            if(tweet != ">restock"){
             digitalWrite(12, LOW);
             digitalWrite(13, LOW);
             Serial.println("LED OFF!");
            }
          
            // close the connection to the server:
            client.stop(); 
          }
        }
      }   
    }
    else if (millis() - lastAttemptTime > requestInterval) {
      // if you're not connected, and two minutes have passed since
      // your last connection, then attempt to connect again:
      connectToServer();
    }
  }
  else if (millis() - lastAttemptTime > 14400000){//if four hours has passed since last feeding
    nikeRestock = 1;
  }
}</p><p>void testing(){
  digitalWrite(12, HIGH);
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);
  
}</p><p>void connectToServer() {
  // attempt to connect, and wait a millisecond:
  Serial.println("connecting to server...");
  if (client.connect(serverName, 80)) {
    Serial.println("making HTTP request...");
  // make HTTP GET request to twitter:
    client.println("GET /1/statuses/user_timeline.xml?screen_name=nikestore&count=1 HTTP/1.1");
    client.println("HOST: api.twitter.com");
    client.println();
  }
  // note the time of this connect attempt:
  lastAttemptTime = millis();
}</p>

Step 7: Finishing the Light

After uploading the programming to my Arduino I put it into the foam housing and plugged it into the cords that I had already installed into the wood housing unit. I then applied a small dot of hot glue into each corner and then put the acrylic box into place.

All that was left is to plug the power adapter into an outlet and plug the ethernet cord into my router. The light will blink once so that you know you have properly set it up. After that its just a matter of waiting until the rare restock tweet gets sent out.