The Best Rootin’ Tootin’ Basketball Shootin’ Tracker in the World

My Basketball Shot Tracker uses two PIR sensors positioned at the rim and below the net of a basketball hoop to track the number of baskets made.

Engineer

Ian R.

Area of Interest

Electrical / Mechanical Engineering

School

The Urban School of San Francisco

Grade

Rising Senior

Final Milestone

My final milestone is the combination of the electrical and mechanical parts of my project. To combine these two different parts, I first soldered my circuit from a breadboard to a protoboard, thereby creating a sturdier and permanent circuit. Then, I inserted this new circuit into the box, and attached it to the power source, which could be an outlet or a portable charger, depending on the location of the hoop. I then connected to the photons via the internet again, and my sensors were ready to go! Although I wasn’t able to do this at Bluestamp, as there was not space for a real basketball hoop there, I also created metal straps that can attach these sensors to the top and bottom of the basketball hoop. The sensor at the top of the hoop sees the first contact of the ball with the rim, and the bottom sensor guarantees that it has passed through the net. When motion is detected by both, it relays it back to the photon and computer or phone. After conducting a few tests, I felt pretty confident about their ability to take in the data of the shots and successfully relay it to my phone through a google spreadsheet.

Video of Shot Tracker Test

Second Milestone

My second milestone is the building portion of my project, or the mechanical part. I needed to be able to attach this electrical circuit to a PIR sensor and a power source from the frame of a basketball hoop, so I knew that I would have to create some form of a case for the circuit. To do this, I built a simple wooden box, with a latch on one side and a simple lock that I made by attaching tape with a slit to the top of the box, which then attaches to a nail, creating a way to open and close the box. Then, I drilled a hole into the side of the box, which then allows me to connect my Particle Photon to a power source. Lastly, I was able to complete a modification that I was interested in for this part of my project, which was to 3D print a cylinder with the perfect proportions to encircle my PIR sensor.

First Milestone

My first milestone is the electrical part of my project. For this part of my project, I created a circuit using a Particle Photon, a PIR sensor, a red LED, and wiring to attach all of these together. The photon is a microcontroller, like an arduino, which means that it can be coded to control what happens in the circuit. The photon specifically has improved IOT features in comparison to a normal microcontroller, which allowed me to connect it, my PIR sensors, and my computer all together through the internet. The next component are the PIR sensors, which use infrared light to detect motion in front of it (this range can be manipulated from 3 to 7 meters). When motion is detected by these PIR sensors, it turns the output of the sensor from low to high, and this causes the current to flow through the circuit, thereby sending the signal to the photon. When this happens, there is also a visual signal of it, as the red LED lights up when the current is sent through it. Using IOT, this signal is then relayed to my computer by the photon, which then stores the data in a google spreadsheet.

Circuit Schematic

iot_screenshot_adczghvdjn-1

Code

Top Sensor

//PIR Sensor (Top of Backboard)

int ledPin = D0; // Establish pin for the LED
int inputPin = D4; // Establish input pin for PIR sensor
int pirState = LOW; // Assume no motion detected at start
int val = 0; // Variable for reading the pin status

void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT_PULLUP); // declare PIR sensor as input

Serial.begin(9600);
}

void loop(){
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
if (pirState == LOW) {
// we have just turned on

pirState = HIGH;
Particle.publish(“Motion_PIR_Top”,”Motion_detected”); //Publish event when motion detected
}
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH){
// we have just turned off

pirState = LOW;
}
}
}

Bottom Sensor

//PIR Sensor (Bottom of Backboard)

int ledPin = D0; // Establish pin for the LED
int inputPin = D4; // Establish input pin for PIR sensor
int pirState = LOW; // Assume no motion detected at start
int val = 0; // Variable for reading the pin status
int score = 0; // Counter variable for shots made
int other_sensor = 0; // Used for delay between both sensors
int this_sensor = 0; // Used for delay between both sensor

void motion_track_score(const char *event, const char *data){
other_sensor = millis();} //Used to track time of motion event from top PIR

void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input

Particle.subscribe(“Motion_PIR_Top”,motion_track_score); //Subscribe to motion of top PIR

Serial.begin(9600);
}

void loop(){
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
if (pirState == LOW) {
this_sensor = millis(); //Used to track time of motion event of bottom PIR

if (abs(other_sensor-this_sensor)<=2000){ //If time between events < 2 seconds, shot is made
score=score+1; //Increment shot counter
Particle.publish(“Basket_Made”, String(score)); //Publish event and shot counter
}

// we have just turned on

pirState = HIGH;

}
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH){
// we have just turned off

pirState = LOW;
}
}
}

Starter Project: Useless Machine

My Starter Project is the Useless Machine. The purpose of the useless machine is in its name: it truly doesn’t have one. When the switch on the top of the machine is flicked from its starting position, the box opens up and flicks the switch back to its original position, and then closes again. I chose this project as I didn’t really love any of the other projects, but really enjoyed the ironic idea of a useless machine and thought it was something that would be fun to have in my room.

How It Works

The Useless Machine is composed of 3 main components: the base, the motor with its accompanying arm, and the PCB, or Printed Circuit Board. As you can see on the outside, the base of the machine is the black box, which gives structure and a foundation to the rest of the machine. The other two components work in tandem to make the machine move or work. The machine is given its purpose and basic instructions by the PCB, which features a switch, a snap switch, two resistors (100Ω and 220Ω), a bi-color LED, and a terminal for the wires of the motor and the battery pack that connects them to the PCB. The PCB routes the power from the batteries to the motor arm, with different instructions depending on the conditions of the switch and snap switch. When the switch is initially flicked, the PCB reads this and causes the motor arm to move up towards the switch. The motor arm then flicks the switch back to its starting position, before moving in the opposite direction, and stopping when it comes in contact with the snap switch. The LED flashes a green light as the motor arm moves up, and then flashes a red light when the motor arm moves back down to its starting position.

Schematic

Leave a Comment

Start typing and press Enter to search

Bluestamp Engineering