3 Simple Model Railroad Arduino Projects for Beginners

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 เม.ย. 2022
  • Parts
    Starter kit that includes all necessary parts (affiliate)-amzn.to/3xAmf7k
    Arduino UNO (affiliate)-amzn.to/36scEUU
    LEDs (affiliate)-amzn.to/3JQqE8o
    Resistors (affiliate)-amzn.to/38ZBD2L
    Breadboard (affiliate)-amzn.to/3Ojb8VV
    Wires (affiliate)-amzn.to/3xzl8Vf
    Ardiuno IDE Software-www.arduino.cc/en/software
    Police Lights Project-github.com/DIYandDigitalRR/Ar...
    Chasing Lights Project-github.com/DIYandDigitalRR/Ar...
    Random Lights Project-github.com/DIYandDigitalRR/Ar...
    Schematic-github.com/DIYandDigitalRR/Ar...
    Connect with me at ddrrcommunity@gmail.com
    Support the Channel on Patreon - / diyanddigitalrailroad
    Amazon Store - www.amazon.com/shop/diyanddig...
    Etsy Store - www.etsy.com/shop/DIYandDigit...
    Facebook - / diyanddigitalrr
    Instagram - / diydigitalrailroad
    TRAIN SETS
    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
    3D PRINTERS
    Elegoo Mars 2 - amzn.to/3yopRaS
    Creality Ender 3 V2 - amzn.to/3DOuKei
    CAMERA
    Sony ZV-E10 - amzn.to/3IK9pX1
    MICROPHONE
    Rode Wireless Go - amzn.to/33ipqDf
    Rode Smart Lav - amzn.to/3dN6ChI
    LIGHTS
    Aputure Amaran 100D - amzn.to/3ELlysm
    Aputure Amaran MC - amzn.to/3ER8Vfw
    GVM 480LS 2 Light Kit - amzn.to/3EOTTGY
    MOTION CONTROL
    MOZA Aircross 2 Gimbal - amzn.to/3oNb4TG
    MOZA Slypod E - amzn.to/3dMWtkQ
    Channel Merch - teespring.com/shop/diy-digita...
    Consider donating the PCOS Challenge to help women everywhere with PCOS
    pcoschallenge.org/
    “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
  • แนวปฏิบัติและการใช้ชีวิต

ความคิดเห็น • 64

  • @rwissbaum9849
    @rwissbaum9849 2 ปีที่แล้ว +6

    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 หลายเดือนก่อน

      Thank you for your input!!
      I am one of those beginner programmers and this info was very helpful!

  • @AlanReynolds
    @AlanReynolds 2 ปีที่แล้ว +1

    I'm definitely saving this one to come back to!

  • @darrellrisley
    @darrellrisley 2 ปีที่แล้ว +1

    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.

  • @vincenthuying98
    @vincenthuying98 2 ปีที่แล้ว +2

    Very cool 😎 vid Jimmy. Love how you make the Arduino Uno so intricately accessible. Thanks 🙏 for sharing!

  • @melkitson
    @melkitson 2 ปีที่แล้ว +1

    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.

  • @johncloar1692
    @johncloar1692 2 ปีที่แล้ว +1

    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.

  • @donaldkormos5529
    @donaldkormos5529 2 ปีที่แล้ว +4

    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.

  • @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

  • @manshedrailroad
    @manshedrailroad 2 ปีที่แล้ว +1

    Heck yeah, I love it!!!

  • @TheSwitchList
    @TheSwitchList 2 ปีที่แล้ว +8

    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

  • @cmmagic62
    @cmmagic62 ปีที่แล้ว

    FANTASTIC intro video!

  • @rwissbaum9849
    @rwissbaum9849 2 ปีที่แล้ว +3

    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 ปีที่แล้ว +1

      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.

  • @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?

  • @Cbtrainnut
    @Cbtrainnut 2 ปีที่แล้ว

    Nice tutorial! I can almost understand! How do you get the lights from the bread board to a police car?

  • @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

  • @kenshores9900
    @kenshores9900 2 ปีที่แล้ว +1

    Jimmy: Very good presentation. My eyes didn’t roll back.

  • @kend3900
    @kend3900 2 ปีที่แล้ว +2

    Very illuminating video !!

  • @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🚂🇨🇦🇺🇲

  • @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?

  • @medwaymodelrailway7129
    @medwaymodelrailway7129 2 ปีที่แล้ว

    Jimmy enjoyed your latest video thanks for sharing DD.

  • @johnschutt9187
    @johnschutt9187 2 ปีที่แล้ว +1

    Do you need a separate Arduino for each of the programs or could they run together on one Arduino?

  • @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 🙏

  • @tubutubutubu5755
    @tubutubutubu5755 ปีที่แล้ว

    You can use a short connecters , we can see easy cuircuit

  • @zoeyzhang9866
    @zoeyzhang9866 ปีที่แล้ว

    Informative tutorial!

  • @user-wg6tm3il2z
    @user-wg6tm3il2z 23 วันที่ผ่านมา

    Hi Jimmy, what do we need to use to power the arduino and can it be done with batteries for these projects?

  • @eugenedrees6163
    @eugenedrees6163 28 วันที่ผ่านมา

    Thanks!

  • @markr5313
    @markr5313 ปีที่แล้ว

    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.

  • @kurtludwig6962
    @kurtludwig6962 19 วันที่ผ่านมา

    Just thinking past learning beginning arduino I have questions
    Stationary steam engine smoke in layout?
    Belt drive machines in saw mill?

  • @yngsjo
    @yngsjo 2 ปีที่แล้ว

    One thing.
    Take a look at the raspberry pi pico (rp2040)
    It's different but like arduino. Nano RP2040 for example.

  • @markr5313
    @markr5313 ปีที่แล้ว

    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

  • @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.

  • @clayton4115
    @clayton4115 10 หลายเดือนก่อน

    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?

  • @joec6054
    @joec6054 หลายเดือนก่อน

    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.

  • @barryolson8428
    @barryolson8428 2 ปีที่แล้ว +1

    Great video. Where r the schmatics and arduino code?

    • @DIYDigitalRailroad
      @DIYDigitalRailroad  2 ปีที่แล้ว +1

      The code is linked in the description as well as the schematic. They are all available on github.

    • @RRWMFan
      @RRWMFan 2 ปีที่แล้ว +1

      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.

  • @Steelerfan820
    @Steelerfan820 2 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      Yes breadboards are for testing. I will sometimes design a PCB for my permanent wiring.

  • @qwincyq6412
    @qwincyq6412 2 ปีที่แล้ว +1

    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 ปีที่แล้ว +2

      Quincy: If you would like to get a better overall understanding of all things Arduino may I suggest checking out Paul McWhorter's TH-cam 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.

  • @DJ_Andreas
    @DJ_Andreas 2 ปีที่แล้ว +1

    Thanks for the good explanation.
    I am not seeing the links you mentioned in the description.

  • @VictorianMaid99
    @VictorianMaid99 ปีที่แล้ว

    How about that !

  • @joec6054
    @joec6054 หลายเดือนก่อน

    Sorry it reads 'pinmode not declared."

  • @danny117hd
    @danny117hd 2 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      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 ปีที่แล้ว +1

      It's a good video. Would've been easier to understand with [ON|OFF]

  • @Kevin9976jj
    @Kevin9976jj 2 หลายเดือนก่อน

    oooooooooooolllllllllllll