Introduction: Arduino Basketball Pop-a-Shot: Upgrayedd

About: I love playing with random things to make random stuff!

I saw the Instructable Arduino Home Basketball Hoop Score Detection System a.k.a. Scorekeeper by ohoilett (thank you for your contribution and inspiration) and really liked what he had going on, but wanted a cleaner version to use as a prize for a pop-a-shot tournament at an event for work. Thus came the upgrayedd, chock full of electrolytes. If you haven't seen the movie Idiocracy, do yourself a favor and put it on the watch list. It will scare the bejeezus out of you.

Step 1: Parts List

SKLZ Pro Mini Hoop (Any indoor hoop will work.)

Arduino Micro

Digital Distance Sensor

Quad Alphanumeric Display

Perma-Proto Half-Sized Breadboard

Enercell Micro USB Charger (Any 5v USB power stick/charger made for a smartphone will work. Make sure the amperage is congruent with your project's draw.)

3-Pin Female to Female Servo Extension (I found one at Microcenter. This one is too short - should be closer to 6")

1/4" & 1/8" thick Acrylic (at any Lowes or Home Depot)

Step 2: Prototyping

Taking ohoilette's concept, I identified that I wanted a basketball hoop that had a visible score displayed, controlled by an Arduino and triggered by a distance sensor focused on the net.

Scaling down the individually mapped LED segments to a quad alphanumeric display with an IC2 backpack from Adafruit made the coding easier and looked sharper than anything I would make from scratch. I really wanted to use a Trinket instead of the Micro, but I couldn't get my sketch small enough to fit on the Trinket. Regardless, downsizing to the Micro made the possibility of fitting it all into a half-sized breadboard a reality. I almost went with the ultrasonic distance sensor until I saw the Sharp digital sensor listed in my parts list. It's much smaller and gets the basic job of motion detection done efficiently.

I created the breadboard schematic above with Fritzing, but here are the connections I used:

  • Arduino
    • 5v > 5v rail
    • GND > GND rail
    • A0 > distance sensor (out)
    • 2/SDA > alpha SDA
    • 3/SCL > alpha SCL
  • Display Sensor
    • OUT > adruino A0
    • VIN > 5v rail
    • GND > GND rail
  • Alphanumeric Display
    • Vi2C > 5v rail
    • VCC > 5v rail
    • GND >GND rail
    • SDA > adrunio 2/SDA
    • SCL > adruino 3/SCL

Code-wise, I created an integer called Score that is always displayed on the alpha display. Every time the distance sensor is tripped, 1 is added to the integer count, thereby updating the score on the display. Here is the sketch:

//include libraries
#include #include "Adafruit_LEDBackpack.h" #include "Adafruit_GFX.h"

//create Adafruit Alphanumeric Display object Adafruit_AlphaNum4 alpha4 = Adafruit_AlphaNum4();

//define integer int score = 0;

void setup() { //set sensor pin to INPUT pinMode(A0, INPUT); //set BAUD rate Serial.begin(9600); //start display alpha4.begin(0x70); //write zeros to all positions alpha4.writeDigitAscii(0, '0'); alpha4.writeDigitAscii(1, '0'); alpha4.writeDigitAscii(2, '0'); alpha4.writeDigitAscii(3, '0'); //display newly written values alpha4.writeDisplay();

void loop() {

//add 1 to the score if sensor voltage is LOW if (analogRead(A0) < 200) { score++; //write score to display data alpha4.writeDigitAscii(3, (score%10) + '0'); alpha4.writeDigitAscii(2, (score%100/10) + '0'); alpha4.writeDigitAscii(1, (score%1000/100) + '0'); alpha4.writeDigitAscii(0, (score/1000) + '0'); //push display data to display alpha4.writeDisplay(); //wait 1.5 sec to eliminate phantom reads delay(1500); }

After all that tested properly, I soldered the components to a half-sized breadboard for mounting to the backboard.

Step 3: Case Construction

I wanted to enclose the unit in plexiglass to help guard from damage and dust. We purchased a sheet of 1/4" and 1/8" thick acrylic. The 1/4" pieces were used to create the walls and the 1/8" piece for the front of the case. Pieces were cut to size with a table saw, then the edges finished with a propane torch.

We couldn't find any acrylic glue, so we went with small screws to connect the walls and lid of the case, as well to secure the full box to the backboard. Using helicoils would have been ideal here, but the pilot holes were small enough to allow for good grip for the screws.

Small notches were put in each side wall with a router to allow access for the distance sensor and Arduino power cables.

Step 4: Mounting

Double-sided Loctite tape was used on the back of the proto board to secure it to the backboard. The acrylic case was laid on top of that and holes were drilled with a drill press to allow connection with screws from behind the backboard.

The battery pack was affixed to the back of the backboard, directly behind the proto board with the same Loctite tape.

We took a small piece of acrylic and put a groove in it with the table saw, which was then super glued to the rim. Another piece of Loctite tape was used on the back of the distance sensor to secure it to the new tab. It was important to make sure the sensor sat low enough to look though a hole in the net, opposed to directly at the rope.

Step 5: Final Testing

This worked on the first test, which was pretty awesome! I was concerned about the net movement giving false readings to the sensor, but I wasn't able to create an erroneous score even with rim shots and air balls. I give credit to the sensor placement in relation to the holes in the net.

The unit is powered on and off by plugging the usb cable into the Arduino (or from the battery pack side.) That pack runs off of 2 AA batteries, and I let it go with a constant count running for around 3 hours without it dying. I'm not sure of the total life, but it ran long enough for me to be comfortable with that power solution. A rechargeable usb power stick would be more efficient.

Overall a fun project and I am happy with the final product. Hopefully it is appreciated by whomever wins it!