-
1Step 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.
-
2Step 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)
-
3Step 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.
-
4Step 4
[Hardware] Solder Ribbon Cable to LCD and Buttons
This is the fun part! You can see how I did this step starting at 4:17 in my video (https://www.youtube.com/watch?v=8G3mvy-2taM&t=04m17s). Here are some tips for soldering:
- Make sure you have the LCD in the correct orientation before you start soldering! you should connect the header end of the ribbon cable to the Pi and make sure pin 1 (the colored wire) corresponds to pin 1 on the LCD while the LCD is in the vertical position.
- I inserted the wire tips through the LCD holes and sort of "hooked" them into the hole before soldering. This allowed the wire to remain stable while I touched the soldering iron and the solder to the pin hole.
- Make sure you keep your soldering iron tip clean and shiny: after each wire, you should brush your iron off on a sponge to make it nice and clean. I also tin the tip of the soldering iron (just apply some solder to the tip itself) before soldering each wire.
- The +5V rail from the Pi connects to both pins 2 and 15 on the LCD. I connected pin 2 (one of the +5V GPIO pins) of the Pi to pin 2 on the LCD, and then used a jumper wire to connect pin 2 of the LCD to pin 15 of the LCD.
When soldering to the buttons, I actually used some extender wire to make it so the buttons could reach their holes in the 3D-printed housing.
When everything is soldered up, the ribbon cable should be able to fit through the shallow notch in the 3D housing.
-
5Step 5
[Hardware] Solder Rheostat to LCD
The LCD requires a rheostat (or potentiometer, or trim pot, or whatever you want to call it) to generate a variable voltage for the contrast pin:
My recommended method of doing this is actually different than what I show in the video (I wound up re-soldering the rheostat after filming that shot).
I soldered the rheostat on the other set of pin holes on the LCD, so it wouldn't interfere with the ribbon cable. I soldered the end pins of the rheostat directly to pins 1 and 2 of the LCD, and then used a jumper wire to solder the middle pin of the rheostat to pin 3 of the LCD. This is how I recommend doing it.
-
6Step 6
[Hardware] Test LCD and Button Connections, Adjust Rheostat to Set Contrast
Connect the ribbon cable to the GPIO header on the Pi. Power the Pi on and execute the StatTrakDriver Python script. Verify that the "Grabbing stats" message appears on the LCD, followed by the messages that display your stats. Verify that pressing the top button causes the display to reset to Infected Killed, and that pressing the bottom button cycles the display to the next stat.
You will most likely need to adjust the rheostat to get the LCD contrast to the point where the letters appear.
-
7Step 7
[Hardware] 3D Print the Trophy
Use the "L4D2 Base w Letters Rev 4.stl" model file to 3D print the trophy.
I would set up a shop on Shapeways where you can order the trophy in the event you don't have access to a 3D printer, but the cheapest option they make available to buyers is $90. Too expensive! You can make your own Shapeways account and upload the .stl file to get access to the $44 PLA option. Again, that's all if you don't have access to a 3D printer.
-
8Step 8
[Hardware] Install LCD and Buttons in 3D-Printed Trophy
The cut-out on the front side of the trophy should be just the right size for the LCD to fit in tightly. Due to tolerance variations in 3D printers, you may have to make the cut-out a little bigger for the LCD to fit. I had to use sandpaper on mine to make the LCD fit!
Depending on the buttons you use, you may have to add support for them so they can actually be pushed. This can be done by inserting a tightly-fit cardboard support beam inside the trophy that the buttons can push against.
-
9Step 9
[Software] Configure Pi to Run Script at Power-up (Optional)
You can configure the Pi to run this script on power-up. First, in the Raspberry Pi configuration, make sure the Network at Boot: "Wait for network" option is enabled. Also, make sure the Auto-login: "Login as user 'pi'" is enabled.
To configure the script to run on Pi power-up, add it to the rc.local file:
sudo nano /etc/rc.local
After the comments in that file, add a command to run the StatTrakDriverRev0_2.py script, then save and exit:
python3 /home/pi/StatTrakDriverRev0_2.py
Now the script will run at the end of the Pi's boot process.
Note: If you don't have buttons installed, make sure you some other way to exit the infinite while loop if you configure it to run at start-up. If you don't have a way to exit it, your Pi will be forever stuck in startup and you'll have to put your Pi's SD card in another Linux machine to go in and edit the rc.local file and comment out the command to run the StatTrak script.
-
10Step 10
You're finished! The Stat Tracker should be able to connect to the internet, download your L4D2 stats, and display them on the LCD!
Please leave me a comment or send me a message if it doesn't work, and I may be able to help you figure out the issue.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.