Introduction: Mechatronic Basketball Shooter

About: Just an ordinary person who loves #thinking and #tinkering

Seeing my Arduino Arm (for Office Catapult) laying around, I was thinking "What else can I do with it?" At the moment I was having my Basketball ring renewed. I need to move my body a little, rather than just sitting in the office. Then this Mechatronic Basketball Shooter crossed my mind. I have an Arduino arm. Can it simulate how to shoot a basketball? Well.. here we go ..

Step 1: Parts Incorporated

  • An Arduino Uno
  • A breadboard
  • A breadboard power supply (we need to separate the power from the Arduino Uno).
  • Some jumper wires
  • 3 micro servos
  • A 10K resistor
  • A 1000uF capacitor
  • A momentary switch/button

Optional parts :

  • Anything you can use as the basket court. Better a piece of plywood. We will screw the servo on it, build the post and the ring.
  • Any stick-shape for the arm. Better a plastic for it is lightweight. Cardboard will do, but will not last for long.

Step 2: The Arm (Cardboard Version)

This is my first arm prototype made of thick cardboard for testing. It works good, but will not last for long depends on how thick the cardboard you are using. On the next step I will show you the plastic arm, more rigid. Keep reading this step to the end to figure out how the servos are connected.

I simply use adhesive tape to join the parts. The cardboard has a length about 2.5" to 3" each. The cardboard can also be attached to the servos' horns with staples through the horns' holes. Cut a "V" for a better hold to the servo's body.

Click to view larger image

The complete arm construction is like the picture above. Two servos on the left have the cables come out from the left and the right servo has its cables come out from the right. This should be done as is for the movement of the arm are determined in the Arduino sketch.

Click o view larger image

Now let's named the servos :

  • Right lower = Servo-1.
  • Left (middle) = Servo-2.
  • Right upper = Servo-3.

The lower cardboard :

  • Right side is connected to Servo-1's horn.
  • Left side is connected to Servo-2's body.

The diagonal cardboard :

  • Left side is connected to Servo-2's horn.
  • Right side is connected to Servo-3's body.

The hand cardboard :

  • This is the palm holding the ball and it is connected to Servo-3's horn (I will re-shape this palm later).

Step 3: The Arm (Plastic Bar Version)

Why plastic? Why not wooden arm? Plastic is lighter for our micro servos which will give more precise timing for the arm to move. I have plenty of them salvaged from old inkjet printers. Pick two pieces of 2.5" to 3" plastic with bar shape so that we can bolt the servos onto it.

The construction is made exactly the same with the Cardboard Version on previous step.

I don't want to hold the arm and basket ring all the time so I get a piece of board for the base. I have one with 10" x 5".

Click to enlarge.

Now we need to screw one of the very bottom servo to the base. The servo is laying by its side, so I need "L" shape adapters to screw it to the base board. I use the plastic on the photo above and I can't remember part of what it was. You can use any "L" shape materials you can find, but metal part will need more work to drill. The point is "we stick the lower servo to the base firmly."

I split it into two and screw the servo like this :

Click to enlarge.

Put the servo's horn on and our arm is ready.

Click to enlarge.

Note :
Beware of the positions of servos like what is described on Step-2. Otherwise you need to change the arduino sketch to make it work properly.

Step 4: Re-Shape the Palm

At the beginning I make a very simple palm that was a flat cardboard with a little fold at its sides. The idea was to hold the ball at standby time (ready to shoot). Later I upgrade it to human-palm-like with curve and a thumb. This curve is simulating our fingers when holding the ball. And when we shoot, the ball will follow the curve with the power of our fingertips.

Click to enlarge.

Well.. here is the new palm :

Click to enlarge.Click to enlarge.
  • Fold both sides of a 3-inches cardboard forming "U" shape.
  • Several cuts on the left and right sides so that we can curve the cardboard.
  • Add a little "L" shape cardboard as the thumb.
  • Stick the cardboard to servo's horn using staples or adhesive tape.

Step 5: Basketball Post and Ring

  • I get another piece of plywood as the post. Measured about 12" to 14".
  • I cut out a bevel on one end to fit my base board's thickness.
  • I get a piece of "L" shape metal to join the post to the base board. I was too lazy to drill holes so I simply use double tape on the joints.
  • For the ring, I simply use a jelly container fastened to the post with a rubber band. I put a piece of paper between the side of jelly cup and the post, to make the ring horizontal to the base board.

Well, you can make a better post and ring of course, or add a backboard to the ring. I will when I have more spare time to kill ;-)

Trivia Basketball Fact

The basket ring is 10 feet above the floor and measures 18 inches in diameter. Basketball: The game ball, which is nine inches in diameter, with between 7.5 and 8.5 pounds pressure.


I am not a pro but I love this game. I call it street ball then for I only have one ring at my working place. The ring is twice as large as the ball in diameter. In this project I am using a pong ball, so I pick a jelly cup approximately twice as large as the pong in diameter.

Step 6: The Ball

Ah.. I love this section much. I have a reason to pick orange pong ball instead of white one. I want to paint it a basketball. If only I had an egg painter bot, but manual drawing is fun for me.

Remember my Peg Hands? It help me in this project by holding a marker for me. Then with both hands I spin the ball under the marker. Not that smooth on first try, but it is pretty close in photos and videos and people will know "Ah.. this is a Basketball Project" by seeing it :D

The ball lines are confusing, but if you look at it closely, you will know how to draw. For starting draw a cross on it, one vertical line and one horizontal line around the ball. Next you will draw something like sine wave line ;)

Step 7: Wiring

Click to enlarge.Click to enlarge.
Know your button. Mostly small momentary switch has four legs which two of them are always connected. If you put the legs up and down as in photo, top left and bottom left are connected, so is top right and bottom right.
If you have a large button, place it in the middle of the breadboard. We will then make this button easy to access.

Click to enlarge.Click to enlarge.Click to enlarge.
My breadboard power fit my half breadboard but somehow it does not match my full breadboard (>.< ) Then I have to connect it partly. Set the jumper to 5V and for the other side that out of the board I set the jumper OFF to prevent short to any metal parts.

Then put four pairs of wires on the power rails. Four on 5V and another four on GND (ground). I used to pick the bright colors for 5V and the darker colors for GND. It doesn't matter what the colors as long as you don't screw up between 5V and GND (^_^ )

Click to enlarge.

Now connect 3 pairs of 5V and GND wires to the servos. Micro servo cable has three pins namely


BrownGround
Red5V
OrangeControl

Connect all the red wires to 5V and all the brown wires to GND.


Click to enlarge.Click to enlarge.Click to enlarge.
Now put a 10K resistor from one pin of the button to GND, I connect it to a free space on breadboard because I have a free pair of 5V and GND wires. Otherwise you can connect it directly to GND rail on breadboard. Then connect the other pin of the button to 5V.
Well, don't get confused by the alternative. In short "Connect one pin of button to 5V and the other pin of button to GND through 10K resistor."

Click to enlarge.Click to enlarge.Click to enlarge.
  • Connect from button pin, where the 10K resistor is connected (orange wire) to Arduino Digital Pin 12.
  • Connect Servo-1 (lower) control pin to Arduino Digital Pin 9 (white wire).
  • Connect Servo-2 (middle) control pin to Arduino Digital Pin 10 (blue wire).
  • Connect Servo-3 (upper) control pin to Arduino Digital Pin 11 (green wire).

Click to enlarge.
Run an extra wire from Arduino GND to breadboard GND. This will help Arduino reads the servos' control pins better and avoid jitter.

Click to enlarge.
Put a 1,000 uF capacitor on your breadboard power rails to help supply power to the servos. Otherwise your servos will misbehave. They will move wildly if they are not fed with the power needed.

Step 8: Coding

This is the Arduino sketch of the mechatronic arm. This is open source so you are welcome to improve this code to get better shoot and post it in the comment section below (^_^ )

/*
 * Chienline @2016
 * Simulating the arm shooting a basketball
 * using Arduino and 3 micro servos.
 */
 
#include <Servo.h>

Servo myservo9;   // Lower 
Servo myservo10;  // Middle
Servo myservo11;  // Upper
const int buttonPin = 12;

int buttonState = 0;
bool readyToShoot = 1;
int i, j, k;

void setup() {
  pinMode(buttonPin, INPUT);

  myservo9.attach(9); 
  myservo10.attach(10);
  myservo11.attach(11);

  standbyPosition();
}

void loop() {
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH){
    shooting();
    delay(4000);
    standbyPosition();
  }
}


void shooting(){
/* 
 * Variables in this part can be adjusted to suit
 * the desired height and distance of the basket.
 * Later it will be developed using two pots to 
 * determine these two parameters : height and distance.
 * Then it could be a robot learning how to adjust by itself,
 * how to move its arm to reach the target.
 */

  while (i>120){
    i-=10;
    j+=25;
    k-=8;
    myservo9.write(i);
    myservo10.write(j);
    myservo11.write(k);
  }
  myservo10.write(130);
  delay(400);
  myservo11.write(180);
  readyToShoot = 0;
}

void standbyPosition(){
  i = 180;
  j = 15;
  k = 150;
  readyToShoot = 1;

  myservo9.write(i); 
  myservo10.write(j);
  myservo11.write(k);
}

Step 9: Powering Arduino and Servos

Place the Arduino and breadboard so that the servos' cables will not twist, and also put the button in a position that is easy to be reached by finger.

On your first run, please unplug all servos' horns. I call it synchronizing the initial position, because we still don't know where are the positions of our servos. Power on the servos and Arduino. It will be at Ready-To-Shoot position. Now you can re-assemble the arm like this :

Click to enlarge.

Arduino and those three servos should be powered by separate power sources. The Arduino itself will not able to power those three servos simultaneously. I use a 12V adapter plug into breadboard power supply module to power the servos and a 5V powerbank to power my Arduino. Later I have a travel wall wart adapter which has built in 5V USB plugs to power my Arduino.

Enjoy the shoot ...

Take - 1 :


Take - 2 :