Old guy new tricks

Hi everyone!
Ok im not totally old, 31 but i feel it lol.

So im starting a new project with my daughter and i am taking my forst step into electronics here.

The basics of this project involving the arduino is that i need to install two sensors in close proximity to a model roller cpaster track.
When the first input is received i want to send some sort of analog output to a stepper motor to spool a line that opens a door to allow the cart to pass through. Once the second sensor is hit i want to reverse the stepper motor and allow the door to close.

I know i need a digital input from a sensor....motion, ir, etc and to send a analog.output to the stepper motor.

So here are my questions......
Whats the best sensor option?

Do stepper motors receive analog input based on the amount of steps you need?

How to reverse the motor to its original position in software?

Is there a kit that will serve this application well? Ive seen a starter kit with a stepper motor and controller.

Im not totally new to programming just new to this language and application. I program building automation applications occassionally now in a data center using a proprietary language thats somewhat close to this.

Any help would be appreciated.

look for motor/stepper control board. they also have a tutorial.

Consider a servo instead of a stepper to operate the gate. Interfacing a servo is way easier than a stepper. The servo library that ships with the IDE makes servo control easy. Sensing the train could be with IR (reflective or break beam), glue a tiny magnet on the train and use hall effect sensors. :stuck_out_tongue:

Stepper motors need pulses of current to make them turn. Arduino card by itself cannot provide that. A shield is needed. Look at motor drivers at www.pololu.com or www.adafruit.com or www.sparkfun.com

The other part, a switch that is wired to connect an input pin to Gnd when closed is all you need to sense a position.
Code-wise it is several parts:

byte buttonPin = 2; // assign a pin name
byte ledPin = 13; // onboard LED for testing
void setup(){
pinMode (buttonPin, INPUT_PULLUP); // input pin with internal pullup resistor
pinMode (ledPin, OUTPUT);
void loop(){
if (digitalRead(buttonPin) == LOW){  // was  button pressed?
digitalWrite (ledPin, HIGH); // turn on LED
else {
digitalWrite (ledPin, LOW); // turn off LED if button is not pressed


You will expand from there to controlling the stepper motor to do whatever.

Thanks guys!
I will look into controlling a servo through the software as that seems cheaper and easier.
Any recommendations on a decent servo that has good torque.

First define "good torque". Look at the RC plane hobby sites for servos of all sizes. Be aware that the Arduino can control servos, but not power them. You should have an external supply for the servos. 4 AA batteries is a good alternative for hobby servos, usually.

What is totally old :o ?

Groundfungus thanks. I plan to power the servo from a dedicated 5v dc source in my power supply and just control from the arduino.

I cant really quantify what im expecting tq wise but something in the arena of 1/8th scale rc steering servo should be plenty.

They are both torquey and quick enough for my needs.

Larry my definition of old scales with my parents ages lol. So for me old is 58+ when i am 58 old will be 85 according to my math

Lots on the Internet about servos.

Always recommended to use a separate servo power supply for the motor, match power supply to motor ratings.

58, that makes many of us ready for the grave, :confused:


if you are opening a free hanging door, then the motor does not need to be that large.
IIRC. the gates on the Panama canal weight like 100 tons, but a man can move them.

in this early stage, get any servo that will work with your power supply and make it work something. if it is too weak, you can move a board or a piece of cardboard or paper.

you have lots of options for motors