Light-up Arcade Basketball game

Materials/Tools

Step 1: Make the structure

For my structure I used three sheets of foam board. I do not have any specific plans for the structure, so be creative and make it how you like it. I also added some dowels along the edges and paint to clean up the look.

Step 2: Download and Print Files

Click the "3D Files on Thingiverse" button below. Download and print the files at its current scale.

Step 3: Add Lights

Add fairy lights around the edges or where ever you would like. Then, strip off the end of the positive and negative wires and twist on a male Dupont pin to each.

Step 4: Put in ultrasonic sensor

Connect four Dupont wires to the ultrasonic sensor. Remember which color wire goes with each pin. Then, put the sensor through the two holes of the hoop and put a hole below the print to put the wires through.

Step 5: ATtach arduino and battery

Use hot glue or double sided tape to attach the Arduino bracket and battery to the back of the game. Use two to four screws to attach the Arduino to the bracket.

Step 6: wire up

Ultrasonic sensor Echo to pin 11 on Arduino. Ultrasonic sensor Trig to pin 12 on Arduino. Ultrasonic sensor Gnd to Gnd pin on Arduino. Ultrasonic sensor Vcc to 5V pin on Arduino.

Positive wire of light to pin 13. Negative wire of light to Gnd pin.

If you do not know which is positive or negative for the lights, try both and one of them should work.

Plug in battery.


Step 7: upload code

Use Arduino IDE on your computer and the cord to upload the code. Copy the following code into Arduino IDE.

Arduino IDE Code

#define trigPin 12

#define echoPin 11

#define ledPin 13


void setup() {

  Serial.begin(9600);

  pinMode(trigPin, OUTPUT);

  pinMode(echoPin, INPUT);

  pinMode(ledPin, OUTPUT);

}


void loop() {

  digitalWrite(trigPin, LOW);

  delayMicroseconds(2);

  digitalWrite(trigPin, HIGH);

  delayMicroseconds(5);

  digitalWrite(trigPin, LOW);


  long duration = pulseIn(echoPin, HIGH, 20000);


  int distance = duration * 0.034 / 2;


  Serial.print("Distance: ");

  Serial.print(distance);

  Serial.println(" cm");


  if (distance >= 0 && distance <= 8) {

    digitalWrite(ledPin, HIGH);

    delay(500);

    digitalWrite(ledPin, LOW);

  }


  delay(20);

}



Step 8: play!

Have fun playing with the arcade basketball game!