Things used in this project

Hardware components:
Photon new
Particle Photon
Microcontroller that does it all
×2
13285 01
PIR Motion Sensor (generic)
Sensors used to track motion of basketball through hoop
×2
Adafruit industries ada64 image 75px
Solderless Breadboard Half Size
×2
09590 01
LED (generic)
Visual for detected motion from PIR Sensors
×2
11026 02
Jumper wires (generic)
×2
826 04
Male/Female Jumper Wires
×6
Software apps and online services:
Q8wtlimqnp04fzhtr9v5
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

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

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Particle Photon Flip Dot Clock
Intermediate
  • 1,851
  • 30

Full instructions

The flip dot display uses an electromechanical dot matrix that spin from black to yellow to display text, numbers and more!

GooglePi - Google Assistant on Raspberry Pi
Intermediate
  • 15,190
  • 85

Full instructions

A DIY Google Home using your Raspberry Pi.

Patriot iOS App
Intermediate
  • 505
  • 9

Use an old iPhone device to control and display the status of your Patriot IoT devices.

Patriot iOS App

Team Patriot

Pre-Collision Assist with Pedestrian Detection - Honda Civic
Intermediate
  • 1,632
  • 19

Full instructions

Combine Walabot's RF radar with real-time hazard detection and classification from camera, powered by TensorFlow with YOLO approach.

Do You Know How Your Plants Are Feeling? [Particle+Ubidots]
Intermediate
  • 136
  • 3

Full instructions

Build and deploy a soil moisture and temperature sensor for commercial greenhouses or private garden monitoring and treatment.

IoT Thermometer Using Python
Intermediate
  • 55
  • 1

Full instructions

How to develop a simple, but powerful, IoT thermometer using a Zerynth-powered single-board MCU and the Zerynth App.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Feedback