3 Simple Model Railroad Arduino Projects for Beginners

  Рет қаралды 43,863

DIY and Digital Railroad

DIY and Digital Railroad

Күн бұрын

Пікірлер
@rwissbaum9849
@rwissbaum9849 2 жыл бұрын
On to my software comment. If you only want to turn one light on, then off, your approach works fine. But if you want to simultaneously control, say 15 lights, the use of delay() will not work. delay() basically stops all processing on the Arduino and you end up losing a HUGE amount of computing power. The solution is to create a class - name it LED - which supports a number of methods, and which monitors whether the LED is currently on or off. At the start of the loop() function, you must refresh the led state by calling, for example, Green.refresh(); where Green is a LED object and refresh() is a method provided by the LED class. Then the rest of the loop() function allows you to modify the state of the LEDs. This makes your sketch look like this (for a simple example): #include LED Red = LED(6); LED Green = LED(A0); LED Yellow = LED(13); void setup() { Green.blink(100,200); Red.blink(250,250); Yellow.blink(500,100); } void loop() { Green.refresh(); Red.refresh(); Yellow.refresh(); } In this example, a red LED is connected to digital pin 6, a green LED is connected to analog pin 0, and a yellow LED is connected to digital pin 13. The blink method (provided by the LED class) turns the LED on for the first specified interval, then off for the second specified interval, then repeats. Here is the important part: there are NO delay() function calls - not in the sketch above, nor in the LED class code in LED.h. Each LED object maintains its own timer, and decides whether the LED should be on or off. Every call to refresh causes the corresponding output pin to be set HIGH or LOW, as required. This frees the Arduino to do other tasks simultaneously. Bottom line: If I could give just one piece of advice to new Arduino programmers, it would be this: find a way NOT to use delay(). It is a very effective way to paint yourself into a corner!
@joec6054
@joec6054 8 ай бұрын
Thank you for your input!! I am one of those beginner programmers and this info was very helpful!
@TheSwitchList
@TheSwitchList 2 жыл бұрын
Hi Jimmy. Nice video - one comment. For the random lights project - the Arduino random(x,y) will return a value between x and y-1, so the sketch needs to be modified to use randomlight = random(3,7), instead of randomlight = random(3,6) - or the LED attached to DIO 6 will never come on. -Rick
@DIYDigitalRailroad
@DIYDigitalRailroad 2 жыл бұрын
good call.
@rwissbaum9849
@rwissbaum9849 2 жыл бұрын
Jimmy, this is a great intro and I hope that Arduino beginners are encouraged to start an Arduino project. I have two comments - one on the hardware and one on the software. Regarding the hardware, I use Nano clones for all of my light and sound effects. You can get Nano clones for about 10 bucks each; name brand Nanos are about 15 bucks if you buy in bulk. (These prices have gone up a LOT due to Covid supply chain issues!) By contrast, an Uno costs over $20, and an Uno clone is between 15 and 20. Since you'll be mounting the Arduino under your layout, each Arduino project becomes a significant cost - say, equal to a ready-to-run freight car. Once I've tested my circuit and software, I mount my Arduinos on a circuit board (or bread board) along with all resistors and connectors. You can get an assortment of 100 circuit boards for $15, and 60 2-pin screw terminals for another 15$ on Amazon. The completed board can be powered by a 15 VDC power bus; no USB cable required. BUT, be sure you can access the USB connector on your Arduino so you can modify the programming later!
@DIYDigitalRailroad
@DIYDigitalRailroad 2 жыл бұрын
I use Nanos too for nearly everything on my railroad. I typically only use UNOs for prototyping. If I need a ton of I/O, I step up to a Mega.
@kenshores9900
@kenshores9900 2 жыл бұрын
Jimmy: Very good presentation. My eyes didn’t roll back.
@DIYDigitalRailroad
@DIYDigitalRailroad 2 жыл бұрын
Always the goal haha!
@donaldkormos5529
@donaldkormos5529 2 жыл бұрын
Thanks for another nice Arduino video!! The Arduino ability to introduce randomness ... using Random(x,y) function calls ... for lighting, sound, and motion controls ... is it's highlight for model railroad applications in my opinion. As you pointed out, it can make a building look more realistic with random room lighting. It can make a city scene look more realistic with buildings being randomly or (semi-randomly) lit depending on the time of day you wish to simulate. I'd like to add this realism with a fast clock so that I can watch my city scene change from one day into another. While each day is similar to the previous day ... each day slightly different from each other as in real life. Suggestion. Maybe you could discuss fast clocks in a video. JMRI has some fast clock features but I don't know how to use them.
@darrellrisley
@darrellrisley 2 жыл бұрын
Great job Jimmy! Love the new format of writing the code then explaining it. I must confess, I watch all your videos but sometimes got bogged down with the line by line explanations.
@thesheq5023
@thesheq5023 2 жыл бұрын
On the last example you should include a time off=rand() as well so they’re not on immediately after one goes off
@BaileyWeathers-m1l
@BaileyWeathers-m1l 8 ай бұрын
Hi Jimmy, what do we need to use to power the arduino and can it be done with batteries for these projects?
@melkitson
@melkitson 2 жыл бұрын
Another nice one Jimmy. Beautifully explained. I have used someone else's example for my Outland Models buildings which makes such a difference. I have more than a dozen lights with the randomness projected to allow more than one light on at any one time. The whole lot could therefore be on at once. I like the simplicity of your presentation and especially the police lights.
@DIYDigitalRailroad
@DIYDigitalRailroad 2 жыл бұрын
Thank you for the kind words!
@kend3900
@kend3900 2 жыл бұрын
Very illuminating video !!
@DIYDigitalRailroad
@DIYDigitalRailroad 2 жыл бұрын
I see what you did there.
@eugenedrees6163
@eugenedrees6163 8 ай бұрын
Thanks!
@chrispainter7894
@chrispainter7894 2 жыл бұрын
Hi from the UK Jimmy and thank you for your great video. Could you please consider a follow up video explaing how you would get the lighting effects actually onto the layout and the wiring involved.... I am imagining a police car sitting on top of the breadboard on the layout! Cheers Chris P
@AlanReynolds
@AlanReynolds 2 жыл бұрын
I'm definitely saving this one to come back to!
@cmmagic62
@cmmagic62 2 жыл бұрын
FANTASTIC intro video!
@Cbtrainnut
@Cbtrainnut 2 жыл бұрын
Nice tutorial! I can almost understand! How do you get the lights from the bread board to a police car?
@johnschutt9187
@johnschutt9187 2 жыл бұрын
Do you need a separate Arduino for each of the programs or could they run together on one Arduino?
@markr5313
@markr5313 2 жыл бұрын
ok so i am new to this programming stuff, i just purchased my first arduino from amazon via your site. now in addition to this arduino down load do i need to also install the GITHUB you talk about or is that automatically installed when i down loaded arduino.
@vincenthuying98
@vincenthuying98 2 жыл бұрын
Very cool 😎 vid Jimmy. Love how you make the Arduino Uno so intricately accessible. Thanks 🙏 for sharing!
@kurtludwig6962
@kurtludwig6962 8 ай бұрын
Just thinking past learning beginning arduino I have questions Stationary steam engine smoke in layout? Belt drive machines in saw mill?
@tubutubutubu5755
@tubutubutubu5755 2 жыл бұрын
You can use a short connecters , we can see easy cuircuit
@clayton4115
@clayton4115 Жыл бұрын
how does one put these projects in the actual model railway layout, you have shown us using the breadboard etc but how is this wired up in an actual place on the model layout?
@johncloar1692
@johncloar1692 2 жыл бұрын
Thanks for sharing!! Love Arduino projects!!
@moisesbursztein2830
@moisesbursztein2830 2 жыл бұрын
Thank you very much, these arduino projects are exactly what the doctor ordered. BTW I don't need another mug but I have to get the one with the coffee and the train.
@Mike__B
@Mike__B 2 жыл бұрын
Out of curiosity, for the first one (police flashing lights) do you need to write the low state to an LED that is already in the low state from the prior iteration? Or is it more just for seeing what's going on in the code at each iteration?
@markr5313
@markr5313 2 жыл бұрын
hey jimmy; hope this message finds you well. so i purchased my first arduino kit and started playing with it. when i ran your chasing lights and random programs i found an issue with chasing lights #6. it comes on at the same time as #3 and does not seem to chase well, second, with the random light #6 does not work at all. now being i am extremely novice to this coding, i was wonder if there is a fix. please advise thank you
@joec6054
@joec6054 8 ай бұрын
I'm new at this and already I have problems!! I built the project but writing the code is the issue... The word "setup" , on my IDE console is RED . How do I get it to Black ? When I try to run the example on my Arduino UNO it gives me an error that pinmode is not defined? How do I correct this? Sorry for the rookie questions.
@gregguise2128
@gregguise2128 2 жыл бұрын
Hi Jimmy. I really enjoy your arduino videos (which I’ve purchased and have started trialling) - thanks for the great work. I question or suggestion for future videos. I have a load of RC plane parts in my garage from when my son was younger - esc, receivers, transmitters etc. This technology seems a lot simpler than dcc to use in rail modelling (for a start, no wiring), with all the same functionality. But there is so little uptake of RC In HO,OO, N gauge. I found a company called DelTang who made a start but seem to be out of business. Is there any chance RC could be an area for future videos?
@manshedrailroad
@manshedrailroad 2 жыл бұрын
Heck yeah, I love it!!!
@barryolson8428
@barryolson8428 2 жыл бұрын
Great video. Where r the schmatics and arduino code?
@DIYDigitalRailroad
@DIYDigitalRailroad 2 жыл бұрын
The code is linked in the description as well as the schematic. They are all available on github.
@RRWMFan
@RRWMFan 2 жыл бұрын
I also do not see the link for the schematic and codes.
@garrettswoodworx1873
@garrettswoodworx1873 2 жыл бұрын
@@DIYDigitalRailroad Jimmy I just checked the description and I'm not seeing the github link for the sketches & schematics. Could you please check & confirm they got uploaded? Thanks!
@davelandry646
@davelandry646 2 жыл бұрын
I'm not seeing the code or any of the links mentioned in the video either. There's a lot of links, but none specific to this video. Like the video a lot, by the way.
@DIYDigitalRailroad
@DIYDigitalRailroad 2 жыл бұрын
@@davelandry646 Try it now, it should be fixed.
@qwincyq6412
@qwincyq6412 2 жыл бұрын
Not so simple for those of us who don’t know an arduino from an aardvark. Is there an introduction to how to do all this? It looks cool but do you need a PC specifically to program one of these projects?
@garrettswoodworx1873
@garrettswoodworx1873 2 жыл бұрын
Quincy: If you would like to get a better overall understanding of all things Arduino may I suggest checking out Paul McWhorter's KZbin channel and looking for the playlist titled "New Arduino Tutorials". Paul's series has nothing specific to do with model railroading but deals directly with understanding and programming the Arduino and is very concise and aimed at pure beginners, like I was when I found his channel. I found it incredibly helpful and it helped me get the maximum benefit from Jimmy's model railroad specific videos.
@qwincyq6412
@qwincyq6412 2 жыл бұрын
@@garrettswoodworx1873 thanks for the tip
@garrettswoodworx1873
@garrettswoodworx1873 2 жыл бұрын
@@qwincyq6412 You're welcome! I think it is a great series, it helped me a bunch.
@Steelerfan820
@Steelerfan820 2 жыл бұрын
Bread boards are just for testing right? All those wires etc. Id hate to have deal with that in a small space.
@DIYDigitalRailroad
@DIYDigitalRailroad 2 жыл бұрын
Yes breadboards are for testing. I will sometimes design a PCB for my permanent wiring.
@markr5313
@markr5313 Жыл бұрын
Hey Jimmy, I have watched this video countless times. I do have a very serious question. In the arduino, can you program it to power down a section of track right at the signal block so that if you are running multiple trains and don't have to scramble to your dcc to power down the locomotive entering that red block
@DIYDigitalRailroad
@DIYDigitalRailroad Жыл бұрын
Yes you can isolate that section and use a relay to power it down.
@4everdc302
@4everdc302 2 жыл бұрын
I do like the insight ya bring to this aspect of the hobby. Who knows the dinosaur might evolve on a future shelf gig🚂🇨🇦🇺🇲
@zoeyzhang9866
@zoeyzhang9866 2 жыл бұрын
Informative tutorial!
@yngsjo
@yngsjo 2 жыл бұрын
One thing. Take a look at the raspberry pi pico (rp2040) It's different but like arduino. Nano RP2040 for example.
@DJ_Andreas
@DJ_Andreas 2 жыл бұрын
Thanks for the good explanation. I am not seeing the links you mentioned in the description.
@medwaymodelrailway7129
@medwaymodelrailway7129 2 жыл бұрын
Jimmy enjoyed your latest video thanks for sharing DD.
@loispadgett6306
@loispadgett6306 2 жыл бұрын
I get lost in the writing of programs. I would like to find some one in my local club who can teach me. I just need to join and go. Hahaha 😂 This time I think I learned a little bit from this. GOD BLESS 🚂💖🚂💖🚂💖
@bruceyoung1343
@bruceyoung1343 2 жыл бұрын
Thank you 🙏
@VictorianMaid99
@VictorianMaid99 2 жыл бұрын
How about that !
@danny117hd
@danny117hd 2 жыл бұрын
Nice video but again I don't like the code. Don't take that personally I don't like any arduino code. Always the same beginner mistakes. 1. You should never have to say think of this as that while explaining code you should make your code read ON | OFF by making constants for ON | OFF. 2. NOTICE HOW HIGH AND LOW ARE ALL CAPS THOSE ARE CORRECTLY DEFINED CONSTANTS ALL CAPS. Timedelay should be all caps because it is a constant. Constants are all caps.
@darrellrisley
@darrellrisley 2 жыл бұрын
I support the code. Don't lose sight of the fact that this code is aimed at beginners. It is simple and easy to understand without the constraints placed on professional programmers. Having taught computer programming for 18 years, understanding the code is more important than industry imposed rules.
@danny117hd
@danny117hd 2 жыл бұрын
It's a good video. Would've been easier to understand with [ON|OFF]
@joec6054
@joec6054 8 ай бұрын
Sorry it reads 'pinmode not declared."
@Kevin9976jj
@Kevin9976jj 10 ай бұрын
oooooooooooolllllllllllll
Animated Model Railroad Building Lights with Arduinos!
22:24
DIY and Digital Railroad
Рет қаралды 18 М.
Using an Arduino for Model Railroad Speed Matching
23:27
DIY and Digital Railroad
Рет қаралды 12 М.
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
The Best 20 Arduino Projects of the year 2024!
14:59
ToP Projects Compilation
Рет қаралды 100 М.
Building a Model Railway to send Coffee
11:09
ProjectAir
Рет қаралды 681 М.
Routing Control for Your Model Railroad Layout with Arduino
21:08
Ron's Trains N Things
Рет қаралды 29 М.
Can You Charge A Phone with Marbles?
18:06
Engineezy
Рет қаралды 1,4 МЛН
I Made an Automated Model Train With An Arduino!
25:20
DIY and Digital Railroad
Рет қаралды 79 М.
When a B-17 Tail Fell With a Gunner Inside
14:08
Yarnhub
Рет қаралды 4,1 МЛН
12 Best Arduino Projects for Beginners in 2024!
7:38
ToP Projects Compilation
Рет қаралды 190 М.
A STRAIGHT FORWARD Guide to Kato Unitrack: Tips, Tricks, and Hacks
11:29
DIY and Digital Railroad
Рет қаралды 17 М.
Make Dumb Electronics Smart for $3
13:13
I Like To Make Stuff
Рет қаралды 770 М.
Workbench Essentials When Starting Arduino! (Beginner Guide)
8:14
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН