Fun Projects for your LEGO MINDSTORMS NXT!

Home     Projects     Help     Contacts

Baseball Batter
Building: Intermediate
Program: Easy

Building Instructions








Use the shortest wire to connect the motor to port A on the NXT, and a medium length wire to connect the ultrasonic sensor to port 4 on the NXT.

Baseball Batter Programming

Use the program Baseball Bat for your Baseball Batter.  This is a simple program that just waits for the ultrasonic sensor to see the ball then swings the bat back and forth, and repeats the whole process.


How to Use the Baseball Batter

  1. Put your baseball batter on the floor

  2. Run the Baseball Bat program

  3. Roll a plastic ball directly towards the "eyes" of the ultrasonic sensor.  When the sensor sees the ball at the programmed distance (14 inches), it will start its swing.  If you roll the pitch at the right speed, then by the time the ball reaches the bat, it will get a good hit.


  • Experiment with different pitch speeds to find out which will result in the best hit.  Just like a real baseball batter, if the swing is a little early (slow pitch), the ball will go into "left field".  If the swing is a little late (fast pitch), the ball will go into "right field".  If you time it just right, it will hit it right up the middle into "center field".  If the timing is way off or the angle is bad, you may get a strike or a foul ball. 

  • Design your own baseball game and make up some rules for it.  Here are some examples:

    1. Make some borders for foul balls

    2. Split the field into left, center, and right areas, and say that a hit is a single if it goes into right field, a double if it goes to left field, and a triple if it goes to center field.  Design some base runners out of LEGOs to keep track of your runners.

    3. Design some "fielders" out of LEGOs that can "catch" (trap) a ball if the ball goes to it.  If a ball is trapped by a fielder than it is an out.

    4. Like slow pitch softball, you pitch to your own team, so you are trying to get the best pitch possible for the best hits.

  • You could try modifying the batter so that it will hit the ball harder.  One way would be to make the bat longer.  You will also need to extend the beam leading to the ultrasonic sensor.  A more advanced way would be to use gears to make the bat swing faster.  Take a look at some of the other projects to see how they use gears to make something spin faster than an NXT motor normally would.

Get nxtprograms.com on CD!
Click here for info

Home     Projects     Help     Contacts


Copyright 2007-2011 by Dave Parker.  All rights reserved. 
All project designs, images, and programs are protected by copyright.  Please see the usage policy.