Arduino Basics: Using sensors on your Model Railroad!

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 เม.ย. 2024
  • Welcome back everybody! Be sure to subscribe! In this video we take a look at arduino sensors and how to properly use them. Sensors are incredibly useful for modeling realistic automated processes on a model railroad like block signals and crossing gates.
    Arduino UNO
    amzn.to/2SX0Vlk
    Infrared Sensor
    amzn.to/2JMirVr
    Photoresistor
    amzn.to/2qzxUiL
    LED
    amzn.to/2PNo62V
    Breadboard
    amzn.to/2RHu6HH
    Resistors
    amzn.to/2DsaJQ6
    Wires
    amzn.to/2Dc84sX
    DC Power supply
    amzn.to/2D8gYaB
  • แนวปฏิบัติและการใช้ชีวิต

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

  • @brucoder
    @brucoder 5 ปีที่แล้ว +4

    Good stuff!
    Two code style comments (I teach C/C++ programming, sorry) -
    Use spaces for better legibility -
    int valA1 = analogRead( sensor );
    pinMode( LED, OUTPUT );
    You don't need the "if" after the "else" or the second test if it is the last option in the if block since there are only two possible states in this case:
    if ( valA1 < 500 ) {
    digitalWrite( LED, HIGH );
    } else {
    digitalWrite( LED, LOW );
    }
    Based on 30+ years of this, these make the code a lot easier to follow - especially in the case of new coders.

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

      Timpraetor Thank you!

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

      @@DIYDigitalRailroad My pleasure - your simplified "chunks" make all of this easier for everyone to follow.

  • @tomcarr1050
    @tomcarr1050 5 ปีที่แล้ว

    Great tutorial Jimmy...This is going to really help when I get around to setting up my signaling system...Thank You Tom

  • @ThePwcj
    @ThePwcj 5 ปีที่แล้ว

    One day I will get busy and use this valuable info. Thank you and take care... Paul.

  • @playingwithtrains7764
    @playingwithtrains7764 5 ปีที่แล้ว

    Another great tutorial. Thanks, Jimmy.

  • @DruSteel69
    @DruSteel69 5 ปีที่แล้ว

    My... you're pretty awesome with electronics. I'm surprised you don't have faller car system running around your layout or your own built. I bet you can do it. Thanks for the tutorial, Jimmy. Happy railroading.
    Drew

  • @JoeG-firehousewhiskey
    @JoeG-firehousewhiskey 5 ปีที่แล้ว

    This was a good one, thanks for sharing. It was easy but very useful

  • @MakingTracksBlog
    @MakingTracksBlog 5 ปีที่แล้ว

    Hi Jimmy, thank you for this video. I'm interested in your experiences with both the IR sensor and the photorestor under low light conditions. Do they still trip properly if it's darker in the train room? Overall, do you prefer using the IR sensor or the photoresistor?

  • @nickhale2900
    @nickhale2900 5 ปีที่แล้ว

    Nice one Jimmy, the clarity of your presentations is much appreciated, you just need to practice your tiepin!. Would it be easy to add extra LED sensors? Would that mean just adding the same commands to the sketch with different pin Nos. etc.?

  • @dacuzzz
    @dacuzzz 5 ปีที่แล้ว

    another awesome video Jimmy.. thx for sharing.. vinny

  • @sniffy2614
    @sniffy2614 5 ปีที่แล้ว

    Thank you :)

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

    WHAT A TEACHER

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

    Can the infrared be replaced with hall effect sensors, as people reaching over the track can activate the infrared sometimes?
    Cheers 🍻 Bob

  • @chrishodge8159
    @chrishodge8159 3 ปีที่แล้ว

    Hi Jimmy,
    Great video, where can I download the sketch?
    Regards Chris

  • @nesr8786
    @nesr8786 5 ปีที่แล้ว

    great show Jimmy ,aww pity next week end of Arduino lessons, look forward to watching though ,thanks regards John

    • @DIYDigitalRailroad
      @DIYDigitalRailroad  5 ปีที่แล้ว

      Thank you! It isn't the last overall. I will have more segments for beginner arduino tutorials later!

    • @nesr8786
      @nesr8786 5 ปีที่แล้ว

      @@DIYDigitalRailroad Great Jimmy thank you very much, theres so much more an arduino can to on railway , a DCC controller, i look forward to seeing if you will do one on working stepper motor for turntable ,theres a project buddy.

  • @sniffy2614
    @sniffy2614 5 ปีที่แล้ว

    Can u do a tutorial on 12v dc motor(or just servo motor) with a sensor??? I really enjoy your channel :)

    • @DIYDigitalRailroad
      @DIYDigitalRailroad  5 ปีที่แล้ว

      I will add that to my episode idea list!

    • @sniffy2614
      @sniffy2614 5 ปีที่แล้ว

      @@DIYDigitalRailroad thank you & take care !!!!

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

    I need to buy a few more UNO's

  • @TOOT222
    @TOOT222 5 ปีที่แล้ว

    Any chance of getting a copy of your sketch, i have typed it in from the screen but it trips up on the IF statement. Syntax in everything so a copy of yout text would be a big help thanks

    • @DIYDigitalRailroad
      @DIYDigitalRailroad  5 ปีที่แล้ว

      I'll go and grab you a copy.

    • @TOOT222
      @TOOT222 5 ปีที่แล้ว

      Thanks I intend to use them to trigger signals if you like you could send a txt file to my email address or you may have a better idea.

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

    I think I need to adjust the trigger threshold.

  • @josephtannenbaum8696
    @josephtannenbaum8696 4 ปีที่แล้ว

    The IR sensor is digital out...Either a high or a low.

  • @fg87fgd
    @fg87fgd 5 ปีที่แล้ว

    The following is open source. Advantage: faster code, better structure, less nonsense.
    // completely parametrize code....
    const int SENSOR = A0;
    const int LED = 13;
    const int SENSOR_THRESHOLD = 500;
    const int DEBUG_MODE = false;
    void setup() {
    Serial.begin(9600);
    pinMode(LED, OUTPUT);
    }
    void loop() {
    // read
    int sensorValue = analogRead(SENSOR);
    // write
    int ledValue = (SENSOR_THRESHOLD > sensorValue) ? HIGH : LOW;
    digitalWrite(LED, ledValue);
    if (DEBUG_MODE) {
    Serial.print(sensorValue);
    Serial.print(ledValue);
    }
    // wait
    delay(100);
    }

    • @DIYDigitalRailroad
      @DIYDigitalRailroad  5 ปีที่แล้ว

      Great stuff! Thanks for the code!

    • @fg87fgd
      @fg87fgd 5 ปีที่แล้ว

      @@DIYDigitalRailroad It's give and take, isn't it? Thanks, mate.

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

    It would really help if this guy put the schematics for these circuits. You cannot really tell the hookups by looking at the video, as they are not 3D. So you have to guess at how the circuit is connected. This made this video extremely frustrating.

    • @DIYDigitalRailroad
      @DIYDigitalRailroad  4 หลายเดือนก่อน +1

      I can certainly make some and add it to them. This video is from a long time ago and I didn’t know how to make schematics like I do now.

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

      @@DIYDigitalRailroad Wow, didn't expect a response because the video was a few years old. Yes, well I am trying to get sensors on my layout, hence the Mega, which I have yet to make sense of. Thanks for your quick response, and I will look forward to the schematics. There are plenty of Arduino type deals on the internet, plus I am trying to make use of the Micro-Cap also. Thanks again! (P.S.) and for Arduino MEGA, because automation and control is dependent on on sensors, and you need a lot of them. Thanks again.