Carlos RocaMichael Gurdak
Published

Hot Shot Hoops

No need to keep track of the number of baskets you make when shooting hoops. Hot Shot Hoops does the work for you.

IntermediateFull instructions provided6 hours1,367
Hot Shot Hoops

Things used in this project

Hardware components

Photon
Particle Photon
Microcontroller that does it all
×2
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
Sensors used to track motion of basketball through hoop
×2
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×2
LED (generic)
LED (generic)
Visual for detected motion from PIR Sensors
×2
Jumper wires (generic)
Jumper wires (generic)
×2
Male/Female Jumper Wires
Male/Female Jumper Wires
×6

Software apps and online services

Maker service
IFTTT Maker service
Used to publish tracked shot data to Google Sheets for graphing purposes.
Particle App
Used to track motion and "made shot" events
Google Sheets
Google Sheets
Made shot data stored and graphed here

Hand tools and fabrication machines

Hand Bender
Used to bend metal strips for attachment to backboard
Impact Driver
Used to fasten metal strips to sensor configuration
Drill Tap
Used to create hole for wire pass-through in sensor configuration

Story

Read more

Schematics

Circuit Schematic

Schematic of circuit set-up
Iot screenshot adczghvdjn

Final Setup Photon

Image of altered design of photon used during testing
Img 0675 qhfmtezheb

Code

PIR SENSOR (Top of Backboard)

C/C++
Code to track motion of basketball through hoop
//PIR Sensor (Top of Backboard)

int ledPin = D0;                // Establish pin for the LED
int inputPin = D1;               // 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);     // declare PIR sensor as input
 
  Serial.begin(100);
}
 
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;
    }
  }
}

PIR SENSOR (Bottom of Backboard)

C/C++
Code to track motion of basketball to hoop
//PIR Sensor (Bottom of Backboard)


int ledPin = D0;                // Establish pin for the LED
int inputPin = D1;               // 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;
    }
  }
}

Credits

Carlos Roca

Carlos Roca

1 project • 2 followers
Contact
Michael Gurdak

Michael Gurdak

1 project • 1 follower
Contact

Comments

Add projectSign up / Login