stepper motor to drop ping pong balls

Hi, this is my first post here so hi. Anyways long story short but I'm buying a shed to put stuff in so I can park my 2 cars in the garage. I would like to use an Ardunio and 2 stepper motors to drop the ping pong balls to desired height for each vehicle to know where to park when pulling and, stay down for a couple minutes and then retract so they won't be in the way when I want to be in the garage working on projects. As far as I can tell making the ping pong balls drop, wait and retract will be east, but I can't find anything on the internet code wise that would tell the arduino to start running the code with some kind of input signal from garage door opener and then reset to beginning of code after operation. Is this something that can be done with the arduino? Btw im looking at buying the uno R3 if that helps, thanks in advance!

First off - look into how to hook up and sense a switch on the Arduino - because that is what you’ll want to do, ultimately. It’s actually very simple:

That example is for a momentary contact button - but for any switch it is basically the same thing.

Now - the simplest way to implement this logic would be to have the Arduino wait until an action happens (the door opening) - then drop the ping-pong balls - then wait until the door is fully open - then pause (for however long it takes to pull a car in) - then retract the ping-pong balls - then wait for the door to close before doing the cycle again - so:

  1. Wait until door begins to open (switch 1 open)
  2. Drop the ping-pong balls
  3. Wait until the door is fully open (switch 2 closed)
  4. Wait N number of seconds (for car to pull in)
  5. Retract the ping-pong balls
  6. Wait until door is closed (switch 1 closed)
  7. Goto step 1

Switches 1 and 2 will be connected in such a manner so that when the door is closed, switch 1 when read by the Arduino reads “closed” (HIGH or LOW depending on how you wire and code the logic). When the Arduino reads the switch 1 is “open” - then it drops the ping-pong balls.

After the ping-pong balls are dropped, it looks at and waits for switch 2 to be closed (again, HIGH or LOW signal) - when that occurs, it knows that the door is fully open. Once it knows that, it begins a timer and counts down the seconds until that number reaches 0 (or counts up until the number is greater than your set-point count/seconds). Then, it retracts the ping-pong balls. Then it waits until switch 1 is closed again, at which point it knows the door is closed, and then it can go back and wait for it to open again, continuing the cycle.

All of the above can be accomplished in the “naive-but-simple” manner (lots of blocking code and delay statements); for this project, that would probably be ok - but if you ever want to expand it - or make it more intelligent - or something like that - you are going to want to implement a state machine; google search this forum and look for “blink without delay” and “state machine” - and you will find an absolute TON of threads discussing this issue.

Finally - step #4 above could also be replaced by a switch - to know when the car has pulled in, instead of waiting for a number of seconds; done right, the driver would know they are parked perfectly (and in fact, the ping-pong balls could be replaced with lights). You could also implement separate sensor switches for each parking space - but once you start doing these things, you will likely want to implement the more complex but better state-machine - which is non-blocking.

Honestly - if you plan on doing more than this project with the Arduino, it will be worth the effort and time to learn and understand how the “blink without delay” example works, what a state machine is (and how it is implemented), and what non-blocking vs. blocking code is, and when/why you should use one over the other.

Good luck with your project. :slight_smile:

I'm pretty mechanical and somewhat electrical savvy. I've never used these devices before but came up with the idea today and did as much research as I could until I hit a road block, Thank you very much for your response and pointing me in the direction(s) of where to go from here! It is greatly appreciated!!! I will continue my research and learning until I know what all I need exactly, but for now I was thinking of purchasing this to get some hands on experience as well. It seems to have a good deal of different components that I could play and experiment with. Would you care to weigh your opinion on this?

Thanks Again! Michael

By far the simplest way to drop ping balls would be with a sail winch servo. It comes in a neat package with all the electronics inside for accurate position keeping.

With a stepper you will need a stepper driver board and a limit switch so your code can figure out where the stepper actually is.