ShreyanRadityan76
Published © GPL3+

Basketball Hoop with Buzzer using an Arduino

Create a child-friendly basketball hoop using either an Arduino Uno or an Arduino Nano.

BeginnerFull instructions provided2,821
Basketball Hoop with Buzzer using an Arduino

Things used in this project

Hardware components

Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
The sensor component
×1
Arduino UNO
Arduino UNO
You can also use the Arduino Nano
×1
Buzzer
Buzzer
The sound component
×1
Breadboard (generic)
Breadboard (generic)
Necessary for construction
×1
Jumper wires (generic)
Jumper wires (generic)
Necessary for construction
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Tape, Foam
Tape, Foam
Any type of tape will work
Basketball Hoop
Any bucket is fine
Circular Stuffed Animal/Ball
Any light ball that you know will not damage your HC-SRO4 sensor will work

Story

Read more

Schematics

Schematics

Remember to use an Active Buzzer

Code

Code

C/C++
Basketball Buzzer with Sensor
const int trig_pin = 12;
const int echo_pin = 11;
const int buzzer_pin = 6;
int distance_cm;
long duration;

void setup()
{
//Setting up the sensor
pinMode(trig_pin, OUTPUT);
pinMode(echo_pin, INPUT);
pinMode(buzzer_pin, OUTPUT);
}
void loop()
{  
//Sensor detecting movement
  digitalWrite(trig_pin, LOW);
  delayMicroseconds(2);
  digitalWrite(trig_pin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig_pin, LOW);
  duration = pulseIn(echo_pin, HIGH);
  distance_cm = (duration*0.034)/2.0;

//If the movement is far away, do not turn the buzzer on
  if (distance_cm >= 10 || distance_cm <= 0)
  {
  digitalWrite(buzzer_pin, LOW);
  }
//Otherwise, turn the buzzer on
  else
  {
  digitalWrite(buzzer_pin, HIGH);
  }
}

Credits

ShreyanR

ShreyanR

0 projects • 6 followers
adityan76

adityan76

0 projects • 2 followers

Comments