Introduction: Mechatronic Basketball Shooter

Picture of Mechatronic Basketball Shooter

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)

Picture of 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)

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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 :

Comments

MDario (author)2016-06-02

Hi, i'm trying to make it, i've almost finished, but i don't know how to set up the servos, for example in the ready to shoot position my servos are more or less at 20,150,0 degrees, do i have to set up in specific degrees?

chienline (author)MDario2016-06-02

actually you can change the initial servo position, but you have to change the movement as well because the servos might go beyond the limit.
For initial positions should be no problem actually. Take off every horn, that is taking apart all the arms. Power on your arduino so that it is now in standby position (servos are now at their initial positions). Now put the arms back together at the shape of human's arm in position to shoot.
Try to shoot and see how the arm moves. Change the movement codes if necessary ^^

MDario (author)chienline2016-06-02

Ok i will try to do that, thanks you so much :D

MDario (author)MDario2016-06-06

Ok i Did it but there is a little problem, i power up the servos at 6V with some batteries but one servo does not work, using the program 2 pieces moves but one piece of arm Not . Could be the current that is Not enought?

chienline (author)MDario2016-06-06

Yes, if any of your servos is not working or moving unexpectedly (make some crazy moves or shaking) that means the power is not enough.
I am powering the servos with breadboard power module which is plugged directly to wall wart. And I power up the Arduino with separate battery power so that the breadboard power module can feed the servos with more juicy power ^^
Remember to add a capacitor on the breadboard power lines to remove jitters on servos.

MDario (author)chienline2016-06-06

Yes i Did it, now everything moves i justeat have to set the shoot, thanks !

chienline (author)MDario2016-06-06

You are welcome. Enjoy the shots ^^

chienline (author)MDario2016-06-02

You are welcome ^^

IanB102 (author)2016-04-18

Im trying to recreate this project, but am struggling in a few design areas. First I couldn't find the plastic pieces for the connecting arms and servo mounting brackets. The connecting arms I made out of a gutter cover. Just cut out the length needed and screwed them to the body and horns. Still haven't found usable pieces for the servo mounting brackets. Secondly, I can't find anyone, to include most hardware stores, that carries a thick cardboard to make my "shooting hand" out of. Can anyone give me some options on places to go for that? Everything else should be fine.

chienline (author)IanB1022016-04-19

Sorry for all that junks you might not find at your place. If you keep looking into junk around you (like me) you might find something -- anything to use.

For the arm, you can use plywood, find a thicker one, about 5 mm will do.

For the palm, well, any cardboard will do. I use LED bulb packaging cardboard. There are many you can use, toys or any other electronic or computer's accessories packaging. If you think it is not thick enough, simply glue another ply to make it thicker.

Most of my projects are oriented on waste(s) around me. I am too lazy to hunt stuffs on the market. And I live in a small city, it is sometimes very hard to find what we need, so I need to think how to use things around me :D

Good luck with your project and please kindly share it here on the comment section ;)

IanB102 (author)chienline2016-04-25

So I've hooked up the circuit correctly and it was verified. I uploaded your code posted in step 8 and my servos started going berserk. Any idea on why this could be? Has there been any changes to the code that may have not been posted?

chienline (author)IanB1022016-04-25

At initial run, please release every servo horns, power on, and wait until every servo has stopped then you can re-assemble the arm. This is mentioned on the last step, because every servo has to go to its initial position.

Make sure you run the servos from external power, not from your Arduino's 5V pin because the power is not enough to run three servos at the same time.

If the servos keep going crazy (nonstop), it means you have some bad wire connections. This happens when we are using breadboard and servo. Some breadboard's holes (I mean the connector pins below) are a little bit loose so it makes a very little connection, while servos need a very stable power. That's why we add a capacitor on the power rails. You can touch (move a little) the capacitor to see if the servos stop or not. You need to make sure the servos stop at their certain standby positions. Move the wires to another holes or even get a better breadboard, or use a better jumper wire.

ireland b (author)2016-01-31

like about how much would this cost to make

chienline (author)ireland b2016-02-01

Forget to mention about 10K resistor and 1.000 uF capacitor but they also cost less than a dollar. Mostly being sold in a pack of 10 just like the push button. ^_^

chienline (author)ireland b2016-02-01

Well, I try to list one by one :

- Arduino Uno : Original on Sparkfun.com costs $25 but you can get an Arduino compatible board on the market for as low as $6.

- Breadboard : Full ~ $4; Mini ~ $3; Micro ~ $2; you can pick any of them.

- Breadboard power module : Around $3 to $4.

- Breadboard jumper wire : 40 pcs for around $2.

- Tower Pro Micro Servo 9G : $4 each; $15 for 6 pcs.

- Large 4 pins push button : $2.5 for 10 pcs.

- Pong ball : At local sport store I pay $1 for 6 pcs.

So it costs approximately $28.5 to $50 depends on what Arduino and Breadboard you are using.

For me, I get all those parts in my testing lab from other projects so it costs me nothing but a brand new Pong ball for IDR 2.000,- or $0.15

The cardboard palm the court base, pole and ring are nothing but junks around me.

I even get a backboard for the ring now :D

About This Instructable

3,330views

54favorites

License:

Bio: Just an ordinary person who loves #thinking and #tinkering
More by chienline:Nightmare RoomRe-Box With Dial LockEscaping With MacGyver Style
Add instructable to: