Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!

Basketball Counting Machine

To design a basketball net which is able to count the number of successful baskets done by the player each time he/she throws the ball.

IntermediateFull instructions provided2 days1,978
Basketball Counting Machine

Things used in this project

Hardware components

MSP-EXP430G2ET Value Line MSP430 LaunchPad™ Development Kit
Texas Instruments MSP-EXP430G2ET Value Line MSP430 LaunchPad™ Development Kit
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×2
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1

Software apps and online services

MIT App Inventor 2
MIT App Inventor 2
Energia
Texas Instruments Energia

Story

Read more

Schematics

SCHEMATICS

Code

CODE

Arduino
const int trigPin = 8;  // to declare pin 8 of msp as trig for ultrasonic sensor 1
const  int echoPin = 6;  // to declare pin 6 of msp as echo for ultrasonic sensor 1

const int trigPin_2 = 19;  // to declare pin 19 of msp as trig for ultrasonic sensor 2
const int echoPin_2 = 5;  // to declare pin 5 of msp as echo for ultrasonic sensor 2

long duration;  // declare a long integer variable duration to store time for sensor 1
long duration_2;  // declare a long integer variable duration_2 to store time for sensor 2

int distance;  // declare a integer distance to store distance for sensor 1
int distance_2;  // declare a integer distance_2 to store distance for sensor 2

int counter = 0;  // declare a variable counter to store the number of baskets

void setup() 
{
  // initialise output pins
  pinMode(trigPin, OUTPUT);
  pinMode(trigPin_2, OUTPUT);

  // initialise input pins
  pinMode(echoPin, INPUT);
  pinMode(echoPin_2, INPUT);

  // initialise serial communication
  Serial.begin(9600);

  // print message serially
  Serial.println("Started");
}
void loop()
{
  // for the ultrasonic sensor 1
  digitalWrite(trigPin,HIGH);  // to enable flow of ultrasonic waves
  delay(10);
  digitalWrite(trigPin,LOW);  // to disable flow of ultrasonic waves
  duration = pulseIn(echoPin,HIGH);
  distance = (duration/2)/29.1;  // to calculate the distance
//  Serial.println(distance);  // print the value of distance (optional)
  if (distance<15)  // if the obstackle is upto distance of 15 cm from the sensor
  {
    // if above condition is true, sensor 2 is enabled
    // for the ultrasonic sensor 2
    digitalWrite(trigPin_2,HIGH);  // to enable flow of ultrasonic waves
    delay(10);
    digitalWrite(trigPin_2,LOW);  // to disable flow of ultrasonic waves
    duration_2 = pulseIn(echoPin_2,HIGH);  // to disable flow of ultrasonic waves
    distance_2 = (duration_2/2)/29.1;  // to calculate the distance
  //  Serial.println(distance_2);  // print the value of distance_2 (optional)
    
    if (distance_2<14) //to check if the ball lies in the range of upto 15cm from the net
    {
      // if the above condition comes true
      counter++;  // increase the value of the counter by 1
      Serial.print("*");  // send the opening bit
      Serial.print(counter);  // send the value of the counter 
      Serial.print("#");  // send the closing bit
      Serial.print('\n');  // start printing further data from a new line
      delay(1000);
    }
  }
}

Credits

Shivam Gupta

Shivam Gupta

10 projects • 6 followers
hmsgupta.3062@gmail.com
Dr. Umesh Dutta

Dr. Umesh Dutta

42 projects • 60 followers
Working as Director of Innovation Centre at Manav Rachna, India. I am into development for the last 12 years.
Ritick sethi

Ritick sethi

9 projects • 5 followers
Texas Instruments University Program

Texas Instruments University Program

91 projects • 120 followers
TI helps students discover what's possible to engineer their future.
Energia

Energia

34 projects • 26 followers
Founder of @energiaproject
Mit

Mit

0 projects • 0 followers
Akash Dubey

Akash Dubey

2 projects • 0 followers
Vaibhav Bhatia

Vaibhav Bhatia

1 project • 1 follower
Vivek Saini

Vivek Saini

1 project • 2 followers
Data Scientist
Muskan Khurana

Muskan Khurana

0 projects • 0 followers

Comments