Tired of rushing to the subway only to see tail lights as it pulls away from the station?

Me too. So I have created a little Arduino powered lamp that changes colors based on when the next train is coming. This one was built using the BART API but many systems have public access to their GTFS Feed(this is what gives you the time until the next train/bus), but check your system's website before starting to build!

Step 1: Gather Materials

  1. Arduino UNO board + Ethernet Shield (though any board with ethernet would work)
  2. Adafruit's Neo Pixels (preferably the breadboard friendly version)
  3. Blank PCB Board
  4. Wires
  5. Soldering Iron
  6. Ethernet cable
  7. Power cable
  8. Web server access (for processing the API data)
  9. Ikea Lamp shade (Ikea Website) OR
  10. 3D Printer and Laser Cutter and materials for that

Step 2: Find Transit Live Feed

This is needed for getting the arrival time.

For example BART's is available here and NYC's MTA feed is available here

Step 3: Set Up Simple PHP Document for Parsing

So the Arduino has a hard time extracting the time for the full feed, so in order to expedite this process it is worthwhile to set up a .php document on your website to get just that information. For example, what it looks like for the BART API to get the next train departing Hayward, CA going North:

<p>$xml=simplexml_load_file("http://api.bart.gov/api/etd.aspx?cmd=etd&orig=HAYW&key=MW9S-E7SL-26DU-VV8V&dir=n");<br>  echo '<'.$xml->station[0]->etd[0]->estimate[0]->minutes.'>';</p>

This will then put the time between '<' and '>' so we can tell the Arduino to just grab that number and use it.

Make sure to add the opening and closing PHP tags!

Step 4: Upload the Arduino With the Code

Please download the attached file and change lines 16 and 21 (the ones shown below) to the location of your PHP script we just set up.

Make sure to leave in the HTTP/1.0 so the Arduino knows what type of party it is going to!

<p>char server[] = "www.fosterport.co";</p><p>String location = "/arduinoTesting/ardi.php HTTP/1.0";

Step 5: Solder Neo Pixels Together and to PCB Board

The number depends on how many you want to use and how bright you need the lamp to be, also the PCB is optional but it is a lot easier to use than just soldering them together in the air and they stay together better.

Step 6: Wire the Arduino and NeoPixels Together

The code uses Pin 6 for the data, and 3.3V for the Power and Ground for Ground.

The Adafruit Best Practices(available here) suggests using a capacitor and possibly an additional resistor, I would go with that if you have them around but I have run these for a few months without them and I have not had any problems.

Step 7: Create Device Inclosure

On the simpler side, you can just buy an Ikea lamp and use that or if you want to get fancy you can 3D print almost anything to put it in. I personally made a little BART car and the 3D model is attached and I laser cut the additional inclosure you see.

<p>This is great... trying to replicate for the NYC Subway! I am running into some trouble setting up the Api to run, which uses General Transit Feed Specification. Any help would be very appreciated! </p>
<p>Awesome work! Very new to the world of Arduino... do you think it would be possible to do this with multiple subway lines using a single Arduino? Thinking maybe 2-3 at once.</p>
Yes indeed! If you wanted to do light up lines I would suggest Adafruits Neopixel strips. Each one of these only needs one digital output so you could do 3 or 5 or 8. Then just make sure you are cuing the Transit API for all the information you need. <br><br>I am working on making a multiline one myself, but it is far down on my projects list.

About This Instructable




More by MrRorschach:Incoming Subway Lamp 
Add instructable to: