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 Based Security System with Alerting
Intermediate
  • 1,246
  • 20

Full instructions

Be alerted to any door or window opening and closing in your house on your smart phone.

Happy Plant Notifier
Intermediate
  • 224
  • 4

Full instructions

Get a text or call if your plant is getting too dry, along with a nice LCD display giving information regarding your plant's health.

My Guardian for the Workshop
Intermediate
  • 136
  • 3

Full instructions

Device will send emails if the door or window has been opened, and will monitor the temperature and humidity of the place.

Smart and Safe Outdoor Plant Watering System
Intermediate
  • 2,406
  • 18

Monitors soil moisture and weather forecasts to give plants just the water they need. Safe garden hose hookup for season long watering.

Christmas Gift Box
Intermediate
  • 3,679
  • 595

Full instructions

Christmas Gift Box plays music and sends an email when it is opened.

Carbon Fiber Vacuum Chamber
Intermediate
  • 3,023
  • 94

Full instructions

Our project is a carbon fiber vacuum chamber that is monitored by multiple particle photons and various sensors.

Add projectSign up / Login