Miniature Basketball Court (Kobe Themed)
by baileyay in Circuits > Arduino
370 Views, 1 Favorites, 0 Comments
Miniature Basketball Court (Kobe Themed)
I made this miniature basketball game for my final project in Professor John Gallaugher's Physical Computing class (Spring 2022). It uses a distance sensor to detect when a shot has been made and plays fun sounds when you do make one. In shootaround mode (yes that is the way it is spelled, look it at the Wikipedia page for it), it will keep your score and then tell you your score when you end shootaround mode. Shot clock mode gives you a 30 second shot clock while playing music you might hear at an NBA arena. The court is laser engraved onto a 30-by-18-by-1/4-inch piece of birch and is a 1:43.38 scale model of an NBA court. The logo in the center is Kobe's logo and the 24 and 8 are the two numbers he wore during his career.
Supplies
-30x18x1/4 inch birch piece
-Adafruit VL53L0X Time of Flight distance sensor
-4-wire STEMMA-QT to alligator clips cable
-Circuit Playground Bluefruit, accompanying battery pack, and micro usb data cable, and three AA batteries
-Adafruit speaker (shown above), accompanying charging cable
-Two alligator clips
Laser Engraved Court
This took me like 3 or 4 hours to design an NBA court to scale in InkScape, I'll attach the .svg file so you don't have to do that.
I edited the size and placement of the numbers that appear in the final product on another computer and those changes are in this file.
If you want to use the court without the designs, just make sure you change the blue lines to black.
The slot at the top of the court is meant to hold a 24-inch long piece of acrylic. I didn't have time to add it but I was going to do a really cool laser engraved picture of Kobe and light it up from the bottom with an LED strip, obviously you can remove this slot before laser cutting if you don't want to do that.
3-D Print
I 3-D printed the ball, backboard, rim, and poles to hold up the basket. The Tinkercad files for all of those are attached. The backboard, ball, and poles are printed in two parts because it's generally not advisable to have an overhanging angle of more than 45° when 3-D printing.
I have a slot in the top of the backboard so you can insert your distance sensor as well as a hole on just the front half so it can see out of the backboard. There is a partial hole for the pole to stick in to and and a small hole for the STEMMA-QT cable to come out of. I made a small mistake because on the back half of the backboard this final small hole should be mirrored over the y-axis.
The rim is designed to guide the ball close enough to the distance sensor for consistency but sometimes it doesn't pick it up so perhaps the square hole at the bottom of the rim could be made even smaller.
I used a more traditional looking rim for my initial design and it will be included too if you prefer the look of that.
Obviously you can change the height of the poles if you want, but I think 7 inches is a good height for a court of any proportion.
I initially 3-D printed a spring board that could hold the ball and then launch it towards the hoop (pictured above), but this design was almost impossible to use so hopefully I can come up with a better one. For now you can just toss the ball in.
Code
My code file is attached below, but here is an explanation of how it works if you'd like to tinker with it.
Basically if you press Button A on the CPB will enter shot-clock mode where it will play a sound you might hear in an NBA arena for 30 seconds and then a buzzer sound will play when time is up. While the audio is playing, I have the distance sensor start ranging and if it picks up an object within 3.3 cm, the CPB will light up indicating a made shot. You can tinker around with the distance used by the distance sensor, I found it sometimes picks up a made shot where none occurred if you go above 3.3 cm, but that was with the old rim design.
If you press Button B, you will start shootaround mode which plays cheers and lights up every time the distance sensor detects an object within 3.3 cm. On every third make, one of 11 or 12 unique sounds is played. You can use this website to turn portions of YouTube videos into MP3 files and download them, that is how I got my own sounds. I just watched compilations of the most iconic NBA announcer calls and highlights of my favorite players pulled clips from those. I'll attach some of those sound files, just note you'll likely have to adjust them in the free program, Audacity, before you can play them on your CPB. This video by Professor John Gallaugher shows you how to do that, skip to about 15 minutes in.
For the reading of the score after you end shootaround mode (by pressing Button B again), I used this website to create an MP3 file of the numbers 0 through 20 and then every tenth number after that (30, 40, 50, ect.). You can create every number 1-100 with these.
Final Product
Here's a video demonstration of the final product.
I hope to make some more improvements to this project next Spring that I didn't have time to implement this time around, like adding a second basket and connecting two CPB's via Bluetooth so they can display the score of two different teams or adding in a 5-digit 7-segment display.