Arduino Mini Basketball

44

2

Sometimes simply playing basketball just isn’t fun enough. Sometimes you want to make the game smaller and more convenient to take around. Sometimes you even want to make bonus points if you’re lucky. That’s why you want to make your own Arduino Mini Basketball!

Grab a random ball and tried to shoot at the button. Look at the LCD display to check out your score. Compete with your friends and see who's the lucky one of the day!

Video of the Project

Supplies:

  1. Scissors (21cm)
  2. Ruler
  3. Blade
  4. Hot glue gun
  5. Utility knife
  6. Arduino UNO
  7. Breadboard
  8. Push button switch
  9. Wire (Dupont Wire)
  10. Arduino LCD display
  11. Cardboard
  12. Resistor 1K
  13. Double sided tape
  14. A ball, preferably soft
  15. A box (19cm x 12cm x 4cm)
  16. Power bank (so that it's portable)

Step 1: Connect the Circuit

This is the easiest step in the whole process. The circuit is easy. There are 2 main steps when connecting the circuit. The clear picture of how the circuited is connected is shown below.

First, you want to connect the LCD display. In my LCD display, there’s only 4 slots needed to connect. Those are VCC, GND, SDA, and SCL. Match the slots to the ones on Arduino UNO. You might want to extend those 4 wires using dupont wires. This way, you could place the LCD display away from Arduino UNO.

Then, you’re going to connect the button. The picture of how to connect the botton switch is shown below. D-pin in my circuit is No. 3.

Step 2: Write the Code

<p>LiquidCrystal_I2C lcd_I2C_3F(0x3F,16,2); //set up LCD<br>int score = 0; //set variable "score" to 0
int rand_num = 0; //set "rand_num" (the probability of bonus) to 0
int total_score = 0; //set this variable representing your total score to 0</p><p>void setup()<br>{
  pinMode( 3 , INPUT);
  pinMode( 4 , OUTPUT);
  lcd_I2C_3F.init ();
  lcd_I2C_3F.backlight();
}
void loop()
{
          lcd_I2C_3F.setCursor(0.0 , 0.0) ; 
          lcd_I2C_3F.print( "Score:" ); 
          lcd_I2C_3F.setCursor(0 , 1) ;
          lcd_I2C_3F.print( "Total:" ); //set up the initial layout of LCD display
  
  if (digitalRead( 3 ))
  {
    
  rand_num = random(0, 9);
    if (rand_num == 0){
      score = 3;
      lcd_I2C_3F.setCursor(6 , 0.0) ;
      lcd_I2C_3F.print( "3 BONUS!!" ); //10% chance of 3 bonus points
    } else if (rand_num == 1 || rand_num == 2){
      score = 2;
          lcd_I2C_3F.setCursor(6 , 0.0) ;
          lcd_I2C_3F.print( "2 BONUS!!  " ); //20% chance of 2 bonus point
    } else {
      score = 1;
          lcd_I2C_3F.setCursor(6 , 0.0) ;
          lcd_I2C_3F.print( "1          " ); //70% chance of no bonus. Add some space after 1 to cover up the letters from previous 
          
    }
    total_score = total_score + score; //add on the previous score
     lcd_I2C_3F.setCursor(6 , 1) ;
    lcd_I2C_3F.print( total_score );
    while(digitalRead( 3 )){
    digitalWrite( 4 , HIGH ); //turn on LED when button is pressed
}
   digitalWrite( 4 , LOW ); 
  }
}</p>

Step 3: Design the Exterior

1. Measure the length of the box. Then cut a piece of cardboard that fits exactly in the box. In my case, I cut a cardboard eith length 21cm and width 19cm.

2. Cut the cardboard into a square with a side lengh of 9cm. Use the utility knife to cut a hole that could fit the button switch extactly. In my case, the diameter of the hole is 3.3 cm.

3. Cut two cardboard with length 7.5cm and width 6.5cm. They are the legs of the basket.

4. Use the hot glue gun to glue the legs onto the board with botton. Then glue all of them to the backboard.

5. Cut a piece of cardboard with length 10cm and width 4cm. Cut a rectangle hole of 7cm x 2cm that could fit the LCD display exactly. Use doublesided table to ensure the LCD display doesn’t fall out easily. Then cut 2 cardboard with length 4cm and width 2cm as the legs.

6. Glue the legs onto the cardboard and glue all of them onto the basket.

7. Take a look at the picures to make more sense of what I was talking.

Share

    Recommendations

    • Beauty Tips Contest

      Beauty Tips Contest
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Frozen Treats Challenge

      Frozen Treats Challenge

    2 Discussions

    0
    None
    AmyandTanner

    16 days ago

    This looks like something I might try!