Basic Arduino Servo Control for Model Railroads
Вставка
- Опубліковано 7 вер 2024
- #modeltrains #modelrailroad #modelrailroading #arduino #diy #servo #arduinoproject
Welcome back everybody! Be sure to subscribe! Today we are taking a look at the model railroad applications for small servo motors. We will be using arduinos to power these servos and in this case, we will be using a push button to activate them. This is a great program for slow throw turnouts.
Sketch download
github.com/DIY...
Servo
amzn.to/3f6o2WD
Arduino
amzn.to/3xZE5y7
Resistor
amzn.to/3hkdsOJ
Button
amzn.to/2QYfitT
Breadboard
amzn.to/2StdkBR
Wires
amzn.to/3uykseB
Check out my Facebook page
/ diyanddigitalrr
Support the channel on Patreon
/ diyanddigitalrailroad
Check out my Instagram
/ diydigitalrailroad
Check out my Etsy Store
www.etsy.com/s...
N Scale Train Set
amzn.to/33TzsbS
HO Scale Train Set
amzn.to/311N17g
O Scale Train Set
amzn.to/3lAZCGu
G Scale Train Set
amzn.to/312Cn09
I do a lot of 3D Printing. Here are some great printers
Anycubic Photon
amzn.to/2SAnJZn
Creality Ender 3
amzn.to/3lkMogX
Camera I use
amzn.to/2SyuPh5
Support the channel with some Merchandise!
teespring.com/...
Connect with me at ddrrcommunity@gmail.com
I do a lot of 3D Printing. Here are some great printers
Anycubic Photon
amzn.to/2SAnJZn
Creality Ender 3
amzn.to/3lkMogX
Original Prusa Mini
shop.prusa3d.c...
Elegoo Mars
amzn.to/386NZSa
Anycubic Mega Zero
amzn.to/3mHfdpi
Qiditech Shadow S 5.5
amzn.to/3cZl059
Samaritan’s Purse
www.samaritans...
Camera Used
amzn.to/2X87yWR
“The godly may trip seven times, but they will get up again.
But one disaster is enough to overthrow the wicked.
Don’t rejoice when your enemies fall;
don’t be happy when they stumble.
For the Lord will be displeased with you
and will turn his anger away from them.
Don’t fret because of evildoers;
don’t envy the wicked.”
Proverbs 24: 16-19 NLT
Thank you Jimmy! This is exactly what I need! I have a bunch of servos from rc helicopters that I can now utilize as switch machines. Great job!
Works great, but I need to be able to use an IR sensor instead of a push button or any other type of sensor to detect a train when it passes to throw the servo one direction and then the next pass to throw the servo back to the start position.
Works great! I used Arduino Mega so just changed digital output to 22 instead of 6. Working up to combining LEDs to indicate servo status either straight or turned. Also will eventually be using PCA9685 because I have 30 servos to control. Thanks
Hi Jimmy. You lost me at the beginning and that is not your fault. I just don't know anything about any of it. I think I would need hands on class to learn. I have always been that way in learning, if I read to learn don't get it but if I see in person I can get it.😏
Thank you for doing this for all who can do it this way. Very well done.
GOD BLESS 🚂🚂🚂💻
joined train masters TV because of u. watched your 1st video NICE.
There is so much to take in I’m this video! I’ll definitely be referring to it once I start animation on my layout
Jimmy: Great video but you lost me when you build the bread board and programed the servo. Drinking Community Breakfast Blend with heavy cream. Rail on!
Very informative, Jimmy, you must have done a lot of research on this - I went to DeVry and I still don't fully understand these things!
Not that I understand, but it would be nice to explain/ reason why you do the positions with the pins. Like why did you pick 6, what does the Resistor do, and why that size. The programming is where I always lose it, because ( this is ME personally) I have no interest in the programming stuff. Just not for me. But I did like how you did the programming, labeled what the commands do and show so short cuts. Good for those people that want to do it, Thanks.
Some of the arduino pins allow for Pulse width modulation or PWM. Pin 6 is one of them. That is why I picked that one. In terms of Resistors. I am not an engineer and I don't do the math for resistance. I just know from tutorials that a 1K resistor works with a momentary push button.
This was great. I'll be using this information soon. Thanks!
Servos servos 30 yrs of RC flying got plenty Good 1's now starts the..Which end goes in the Cement Jimmy.!!?? LOL I'm trying
great code and patience
like the update.
Try MEGAPOINTS CONTROLLERS IN THE UK. ALL PLUG AND PLAY AND WORKS BRILLIANTLY.
Legend! Thanks :)
Wow, great!! Thank you for sharing!
This is fantastic. I have one servo working with this information. Now how do I get the other nine servos to work, or am i missing something?
Thanks Jimmy. Will you be doing this with signal and control panel indicator led’s as well? That would be great.
Yes I have a lot planned.
Jimmy -- thanks. I love your arduino tutorials and look forward to what (I hope) will be how to attach the servos to crossing gates and/or turnouts. I do have one suggestion, though. Before typing out the code, could you show a little drawing with the pseudocode? It might make it easier to understand the logic of what follows. Either way, though, great tutorials. Thanks again.
Wondering if and where this could be added to work with the SENSORs VIDEO
Well done Jimmy! Thank you
Evening Jimmy. I'm trying to use your sketch as a repeatable base in order to run more than 1 push button controlled servo. Have you by chance expanded your sketch to do such a thing over the past year? Any help or direction would be appreciated. BTW, got your sketch working well with my hardware!
Can you also put 2 different servo’s with 2 different buttons at 1 arduino?
Hey pal, it would be great if you included a diagram or schematic of the wiring layout. I couldn't find it.
Hello i have 2 questions. First is there a way where i can join the 5 dollar level but pay in dollars not euros? As they charge 5 euros plus a vat tax to join per months. I have a bank in America. Sec question I say a video somewhere you made tell how to take a ho model and convert it to print on a 3d printer but in N scale for model railroading. Thank you.
Hey Jimmy...good video....of course I have to ask...why aren't you using digital pins? Basic code: int buttonState = 0; then buttonState = digital read(buttonPin); and then do the code for state high and low aka on and off....this way when layouts get bigger with more and more buttons and servos you won't run out of pins as you can use analog pins as digital pins. Just a tip for future code and tutorials.
One reason for going the analogue way is to avoid having to cope with bouncing. When you press a button, it doesn’t happen instantly, but rather in a on-off-on-off way (multiple times that is), so you have to verify that it really is a push. Also, the bounce could easily be interpreted as multiple pushes. Doing the analogue is kind of easier to do instead
@@DeStoreholmskeBaner you can account for the debounce in several ways...and in most of my code I haven't needed any debounce....the basic digital button code works just fine...it can be found in the example sketches. Also you can add code to look for multiple presses and ignore those presses.
Super video
What code changes must be made to use a toggle switch rather than a momentary contact button.
It depends on the toggle switch. You could actually simplify the code a great deal depending on which one you used.
Thank you. A double pole, single throw, either on on or on off on. I an struggling with arduino and sure would appreciate seeing that code.
How would I make this work with continuous servos? I bought some 360 degree spinning ones by accident and am struggling to make the work…. Do
I just need to bin them and start again?
Great explanation of the code! I'm curious if you had any issues with the Arduino not having enough power for the servo? I tried using servos with an Arduino, one servo using 2 buttons to turn it. After three uses, the pin stopped working, tried another one, and that stopped as well. The Arduino essentially was unusable. What I could find on this is the the Arduino can't handle the amperage of the servo. Could turning off the servo in the code eliminate this?
Jimmy, could this be activated by a sensor instead of by push button
To use the servo to switch a HO switcher, what kind if wire do I need?
How attach 16 servos to PCA9685 ? Please make a video and give Arduino sketch also .
As usual I'm lost. Right now I wish you were here helping me. I just got a Digitrax Evolution starter set and can't get it to work. My DCS 210+ will not read the track and I can't get my DT602D to work with it. If I replace the 210 with a DCS 100 it will. I don't know if I got a bad 210 or am I doing something wrong! Anyway I'm still trying to have fun, Chris lol not.😩😥
A lot of times with products like this, they can have issues in the firmware they were loaded with that was fixed in later versions after they left the factory. I would try to update the firmware on all of your devices. Here is a link to all of the firmware downloads from digitrax www.digitrax.com/downloads/. They have instructions on how to install the firmware there as well. I'm sorry you're not having fun and I wish I could do more!
Thank you Jimmy, I actually moved the Local Net cable from port A to C and plugged my remote into A and it worked. I'll still do the update and I let Digitrax know, Chris
You never explained how to actually center the servo and find out where "center" actually is, as it is critical to center the servo so you can correctly mount the control horn to be able to switch the turnout effectively.
Ummm. Huh? I dont get it
Nice video, but the music is very annoying after a while!
Could you be anymore confusing with your coding, it is just about impossible to follow what you are doing. Try "Little Wicket Railroad" coding for servos, it makes more sense and is easer to follow.
Also the IoTT channel has a great how-to, broken down into three videos (17,18 & 19), on adding the whole thing for DCC operation.
I disagree. I found this to be very well done and very clear. That said, reviewing other videos and other code always helps as you may not want to do exactly what Jimmy has done.