want to turn on dc motor when train goes by and turn off motor when train goes by another sensor down the track. I am turning on a water wheel and motor only has to go forward. I can use a timer set up also , around 10 to 15 seconds. thx
Not sure what your question is, but here is a MOSFET motor driver. Pick a MOSFET that can handle the stall current of the motor.
Using millis() for timing, a tutorial.
Several things at a time, another millis() timing tutorial.
For the sensor(s) you could use a light gate. Google "light gate arduino" for more information.
Or attach magnet to the train and use Hall Effect sensors.
Adding to post #3
Current sensing
Reflective IR sensor
I would think the reflective IR sensor would be a good choice. You could put a small mirror ( < 1/4" sq) on the bottom of the engine or 2nd car. the sensor would peak through a hole inside the tracks.
If you find other lights are sensed by the receiver simply pulse the LED and verify the reflected signal is pulsing at the same frequency.
What scale? I'm assuming a model but in fact you didn't say... Size does influence the choice of solution somewhat.
Hello,
make a basic design using a H-bridge and a sensor for current per rail track and test.
ho scale -
Part of the answer lies with what is visually acceptable
I would get an IR sensor and put it under the track have it look up
When a trane passes check results.
You could hide in shrubbery
You could hide in bridge overpass
Hide in sign posts.
Or in rocks
dave - you helped me before , have another project that I need help with.
I am building HO Scale coal dumper with a linear threaded rod that I am turning with a 6vdc N20 motor. It will position a coal car to the dumper by pushing it on the linear track with a servo arm . The servo SG90 will move arm 90 degrees to go between cars to position them for the next coal dumping movement. How can I have the servo go 90 degrees with a push button that I can push 1 time for the arm on servo to go down and then push another button for servo arm to come up ?
I have a mega 2560 and Nano Boards.
THX
GK
Can the same button run the servo to 90 on one press and back to 0 with another press?
Like this example?
// press button once servo to 90°, press again servo to 0°.
// by groundFungus aka c goulding
#include <Servo.h>
Servo servo;
const byte buttonPin = 12;
const byte servoPin = 7;
bool buttonState = 0; // current state of the button
bool lastButtonState = 0; // previous state of the button
bool mode = 0;
void setup()
{
Serial.begin(115200);
pinMode(buttonPin, INPUT_PULLUP);
servo.write(0); // servo intial position
servo.attach(servoPin);
}
void loop()
{
static unsigned long timer = 0;
unsigned long interval = 50; // check switch 20 times per second
if (millis() - timer >= interval)
{
timer = millis();
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);
// compare the new buttonState to its previous state
if (buttonState != lastButtonState)
{
if (buttonState == LOW)
{
// if the current state is LOW then the button
// went from off to on:
mode = !mode; // toggle the mode
if(mode)
{
servo.write(90);
}
else
{
servo.write(0);
}
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;
}
}
This morning, I had no idea what a coal dumper was. Now I do; nonetheless, it would be nice to see a picture of what you're making.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.