Close
0%
0%

Left 4 Dead 2 Stat Tracker

A Left 4 Dead 2 Stat Tracker that shows off how good you are at killing zombies.

Similar projects worth following
The Left 4 Dead 2 Stat Tracker exhibits your L4D2 stats so you can show off to your friends how many zombies you've killed! Powered by a Raspberry Pi 3, it automatically grabs stats from your Steam Profile Page over WiFi and displays them on an LCD. Keep it on a shelf in your game room so everyone knows you've got zombie-killing credentials!

Here is a video summarizing what the Stat Tracker is, how it works, and how I made it.

The Stat Tracker rotates between displaying the following stats, which are refreshed every 24 hours or when a button is pushed:

  • Infected Killed
  • Average Kills Per Hour
  • Games Played
  • Finales Survived
  • Whatever else I can think of to add!

It consists of a 3D-printed "L4D2" trophy that houses an LCD. The LCD connects directly to a Raspberry Pi's GPIO header via a 40-pin ribbon cable, so a bulky breadboard doesn't have to be used to wire it all up. The Pi runs a Python script that accesses the user's Steam Profile L4D2 stats page to pull the stats listed above.

I've noticed that video game collectibles and other nerd culture items have been becoming more and more popular over the past few years. With video game companies increasingly adding features to keep track of player stats, I think there is a good market opportunity for a stat tracker that people can buy and have their personal stats from their favorite video game displayed with their other collectibles. I am exploring this market space and gauging the amount of interest there is in such a product.

Hardware:

A Raspberry Pi 3 powers the Stat Tracker. I'm using the Pi 3 because it has built-in WiFi capability, can easily run Python, and is inexpensive. The LCD is an Adafruit 16x2 RGB character LCD. The two connect over a 10" 40-pin ribbon cable that I got from the scrap bin at work. I cut off one end of the ribbon cable, stripped the individual wires, and soldered them up to the pins of the LCD.

There are also two general-purpose buttons connected to the Pi. Pushing the top one refreshes the stats, and pushing the bottom one rotates the display to the next stat.

The L4D2 "trophy" that houses the LCD is 3D printed from a model file created in Blender. I used www.shapeways.com to 3D print the trophy.


Software:

A Python script drives the Stat Tracker. It uses Python's built-in urllib library to load the Steam Profile L4D2 page, and then parses it with Beautiful Soup 4. The Infected Killed, Kills Per Hour, Games Played, and Finales Survived stats are all stored in similar tags in the HTML structure, so BS4 makes it easy to find them. It also uses the Adafruit Character LCD library to display stats to the LCD. An infinite loop runs to scroll through the displayed stats once a minute, refresh the stats every 24 hours, and watch for button presses.

The Pi is configured to connect to my WiFi network and run the Python script upon initialization, so the Stat Tracker just needs to be plugged into power and it will begin displaying stats.

My Github repository with the Python script is located here:

https://github.com/EdjeElectronics/L4D2-Stat-Trak-Driver


BOM:

Raspberry Pi 3 Model B - $35.00

16x2 RGB character LCD - $13.95 (https://www.adafruit.com/products/399)

6 - 10" 40-pin ribbon cable - $2.95 (https://www.adafruit.com/products/1988)

2x pushbuttons - $0.53 each (http://www.digikey.com/product-detail/en/e-switch/KS-01Q-01/EG4791-ND/2116270)

3D-printed housing - $44.09

Total cost - $97.05

Adafruit_399_spec_sheet.pdf

Datasheet for the LCD. I wound up referencing this a lot, especially while defining the interface connections between the Pi and the LCD.

Adobe Portable Document Format - 330.68 kB - 03/13/2017 at 21:24

Preview

Wiring table.JPG

Table showing which pins on the Raspberry Pi GPIO header are connected to which pins on the LCD, and which are connected to buttons

JPEG Image - 79.49 kB - 03/13/2017 at 20:58

Preview

L4D2 Base w Letters Rev 4.stl

3D model file of L4D2 trophy and LCD housing

Standard Tesselated Geometry - 163.17 kB - 03/13/2017 at 05:39

Download

  • Finished making my video!

    Evan Juras03/07/2017 at 07:13 0 comments

    I've finally finished making the video! I'm doing the first full render right now. I'll watch it a few times and see if it needs any changes made. If I'm satisfied, I'll upload it to YouTube and link it here!

    It was pretty fun learning how to use video editing software and having my eyes opened to how much work they must do in Hollywood to get their movies edited just right.

  • Prettifying This

    Evan Juras02/10/2017 at 23:38 0 comments

    Painting the L4D2 block letters red in an ongoing effort to make this thing look cooler! I found a good bright red acrylic paint that matches the color used in the Left 4 Dead 2 logo. Looks like it's going to take a couple coats of paint to make it so the black 3D-printed plastic doesn't show through.

    I'll also be adding a sticker on front with this image:

    Hoping it turns out well!

View all 2 project logs

  • 1
    Step 1

    [Software] Download Script and Install Python Libraries

    Start with a Raspberry Pi loaded with the Raspbian OS. Make sure your Pi is up-to-date by issuing the following commands in the terminal:

    sudo apt-get update
    sudo apt-get dist-upgrade

    Download the StatTrakDriverRev0_2.py python script located at https://github.com/EdjeElectronics/L4D2-Stat-Trak-Driver, and put it in the Pi's home directory (/home/pi).

    Follow the directions on my GitHub README page to install all the necessary libraries for Python 3.

  • 2
    Step 2

    [Software] Modify Python Script

    Use your favorite text editor (I like the Python 3 IDLE) to change the URL in the StatTrakDriverRev0_2.py file to the URL that links to your Steam Profile Page. Also, change the "Taxi-guy\s' \nL4D2 stats" string to your own username. (Unless you just want to display my stats, that's cool too :D )

    You may want to test it at this point by replacing all lcd.message('<string>') calls with a simple print('string') command, and the executing the script. You should see the following output (actually, the break lines won't look as nice, but the text will be there):

    Grabbing stats
    [Username]'s stats
    Infected killed:
    #####
    Average kills
    per hour: #####
    Games played:
    ###
    Finales survived:
    ###
    Infected killed:
    #####
    ...
    ...
    (repeats until execution is terminated)

  • 3
    Step 3

    [Hardware] Prepping the 40-pin Ribbon Cable that Connects the Pi's GPIO to the LCD

    In this step, you will prep the 40-pin ribbon cable (https://www.adafruit.com/products/1988, or whatever else you can find). Prepping and soldering the ribbon cable to the LCD allows the LCD to be easily attached and detached from the Pi, and makes it more space-efficient and manageable than using a breadboard.

    First, review the Wiring Table I've provided in my project files on this page. This states which pins on the GPIO will be connected to which pins on the LCD. Any of the ribbon cable wires that are unused will be cut off.

    Cut the connector-header off one end of the ribbon cable, as close as possible to the end so you don't waste any length of ribbon cable.

    Then, follow the directions starting at 3:36 in my video (https://www.youtube.com/watch?v=8G3mvy-2taM&t=03m36s). Notes:

    • When cutting and peeling the wires (steps 1 and 2), be careful not to cut into the actual wire inside the ribbon cable.
    • When cutting off unused wires (step 3), have the Wiring Table handy and make sure you are cutting out the correct wires. Remember, the red wire indicates pin 1.
    • After stripping the wires (step 4), twist the ends with your fingers so they are more manageable. I also soldered the tips of the exposed wires to make them less likely to fray.

View all 10 instructions

Enjoy this project?

Share

Discussions

FoinB wrote 03/08/2017 at 10:05 point

Hi, Cool project!

Can you upload the Python script?
I would like to build it!

  Are you sure? yes | no

Evan Juras wrote 03/13/2017 at 02:21 point

Hey, sorry for taking so long to respond to this! Here is the file on github:

https://github.com/EdjeElectronics/L4D2-Stat-Trak-Driver/blob/master/StatTrakDriverRev0_2.py

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates