Arduino for Lego Trains #2: Light Sensors

Поділитися
Вставка
  • Опубліковано 26 жов 2024

КОМЕНТАРІ • 56

  • @CrouchStuart
    @CrouchStuart 6 років тому +1

    This one took me ages to get it to work! I realised that my coding is far from expert. I played around with some of the LDR values and it now works great. I also had to swap around the polarity of my three-pin LDR (and add a resistor). Thank you :-)

  • @erhanalankus
    @erhanalankus 9 років тому +5

    I think it's great that the train does not stop instantly. It is important for kids to know that a train can not stop easily.

  • @WillThat
    @WillThat 9 років тому +4

    I wanted this set so bad when I was a kid.

  • @mahaemam4292
    @mahaemam4292 8 років тому +2

    hello can you write the list of the components in this idea? .. thanks in advance

  • @Twoloosebricks
    @Twoloosebricks Рік тому

    so how do I add in a second sensor for station #2, so that it stops and starts at both, Ive been working on it for a week and cannot get it.. tried just about everything, but im not that great at it either. any help is appriciated.

  • @axltrain838
    @axltrain838 9 років тому +2

    awesome.

  • @wimwilkes5643
    @wimwilkes5643 9 років тому +1

    Hello.
    I am Wil Wilkes from The Netherlands. I've watched movie on youtube and I also tried it at home and it works. thanks
    I have 2 lego trains crossing at an intersection, I want to protect the trains with Arduino that they can not crash each other.
    Do you have an idea how to make it?
    greetings Wil Wilkes

    • @ArduinoLegoTrains
      @ArduinoLegoTrains  9 років тому +1

      I do! If you subscribe, I will add a video on how to do this very soon - it will Video #6 in this series.

    • @wimwilkes5643
      @wimwilkes5643 9 років тому

      Arduino Lego Trains When train 1 ride across the intersection. Then train 2 and 3 stop. If train 2 ride across the intersection, then train 1 stop. But train 3 don`t have to stopIf train 3 ride across the intersection, then train 1 stop. But train 2 don`t have to stop

    • @ArduinoLegoTrains
      @ArduinoLegoTrains  9 років тому

      I'm not sure how you have three trains on one intersection. But to solve your problem you should use a Finite State Machine.
      How many tracks are you controlling with the arduino?

    • @ArduinoLegoTrains
      @ArduinoLegoTrains  9 років тому +1

      wim Wilkes Hi Wim. If you haven't seen it already, the Train Crossing tutorial is available here: ua-cam.com/video/YqTgpuXnWeI/v-deo.html
      That should help you get started with your train crossing scenario.

  • @riemerdijkstra5974
    @riemerdijkstra5974 11 місяців тому

    I always like to watch my lego tutorials for the blood and gore

  • @Cowland
    @Cowland 7 років тому +3

    How do you do it with power functions

    • @ArduinoLegoTrains
      @ArduinoLegoTrains  7 років тому

      Check out Tutorial 11 in this series to see how to control Power functions trains.

    • @Cowland
      @Cowland 7 років тому

      Arduino Lego Trains I mean can u still do the same light sensors and all that cool stuff you designed for 9v with power function

  • @mikezang2008
    @mikezang2008 9 років тому +2

    Hi, can you tell me the product no of optical sensor?

    • @ArduinoLegoTrains
      @ArduinoLegoTrains  9 років тому

      Zhengrong ZANG Sure, it's an LM393 Light Sensor Module.

  • @WhoWantsToKnow81
    @WhoWantsToKnow81 9 років тому +3

    1:00 No blood on the train though xD

  • @geecool345
    @geecool345 9 років тому

    Hi! Where do you get your sensors? I've looked around a bit on places like element14 but I can't seem to find these kind of sensors. I dunno, maybe I'm looking in the wrong places. Where did you get yours? Cheers.

    • @ArduinoLegoTrains
      @ArduinoLegoTrains  9 років тому

      +Ryan Stickland I get them from my local electronics store here in Poland, but they're very common components. I don't know where in the world you are so I can't recommend a specific store, so try searching "arduino photoresistor sensor".

    • @NiCadHeliPilot
      @NiCadHeliPilot 8 років тому

      +Ryan Stickland SparkFun & Adafruit are a couple of good places I'd recommend.

    • @wimwilkes5643
      @wimwilkes5643 8 років тому

      I get them by AliExpress, very sheep

    • @srtking2
      @srtking2 8 років тому

      try mindsenser.com

  • @vadimsalomatin4903
    @vadimsalomatin4903 3 роки тому

    Cool!

  • @Travler-xr
    @Travler-xr 5 років тому

    Do you need add resisters along the wire to protect arduino? If so how many ohm?

  • @linkslut
    @linkslut 7 років тому

    Hiya. With the arduino inside the train (for PF trains, mentioned in video #11). How would you get information from a track-based sensor to the train-based arduino?
    Alternatively, how would you move this to train-based?

    • @ArduinoLegoTrains
      @ArduinoLegoTrains  7 років тому +1

      All will be revealed in the next tutorial, which will be published this weekend! Big hint: 433Mhz wireless transmitters.

    • @linkslut
      @linkslut 7 років тому

      Looking forward to it, as I'm just about to begin my Lego Train journey. It's all PF-based, and stopping at stations is very important.

    • @ArduinoLegoTrains
      @ArduinoLegoTrains  7 років тому

      If the sensors are at stations, then you can just run an IR led to the top of the station from your trackside arduino, with no need to add an Arduino to the locomotive. That's the basic principle shown in Tutorial 11. Even if you have Arduino on board (like Tutorial 12) the train still has its IR receiver, and can accept commands from any arduino/IR Led it has access to :).
      The next video removes the train's IR Receiver, so that solution will be a bit more complex.

    • @linkslut
      @linkslut 7 років тому

      I had been looking at removing the IR Receiver and replacing it with an sbrick anyway, so that's not an issue for me. At this point I think I may hold off planning anything until I've seen your next couple of videos.
      I'm also going to want more and more functionality as time goes on, so I will be following your videos eagerly.
      Is your code downloadable anywhere?

    • @ArduinoLegoTrains
      @ArduinoLegoTrains  7 років тому +2

      Sure! Visit arduinolegotrains.wordpress.com and check out the CODE tab at the top; you can copy code for each tutorial from there.
      Hopefully the next video will save you some money, as the S-brick is quite expensive and my solution is 1/10th of the price.

  • @axltrain838
    @axltrain838 8 років тому +1

    so, is 1023 really bright and 0 really dark?

    • @CrouchStuart
      @CrouchStuart 6 років тому

      This is what confused me for a while... I had to reverse the polarity of my LDR (with resistor) to get the code to work properly. Hope this helps :-)

  • @MinifigologyGuy
    @MinifigologyGuy 9 років тому +2

    Ever tried integrating a raspberry pi?

    • @urkm
      @urkm 9 років тому

      Minifigology Guy I think that wouldn't be very much different ;)

  • @xyz22556
    @xyz22556 8 років тому +1

    can you use arduino for PF lego trains?

  • @NielsAL1988
    @NielsAL1988 8 років тому

    I built a Dutch NS train. For the perfect control I used the Arduino Uno rev 3 with a L298 motor controller and LM393 light sensor.
    The problem is that the train doesn’t stop when he passed the light sensor. The sensor detects the train as you can see in the pictures.
    imageshack.com/a/img923/9739/vmeSkM.jpg (sensor detects nothing)
    imageshack.com/a/img922/9409/wRazSO.jpg (sensor detects the train)
    imageshack.com/a/img924/2663/06S9nL.jpg (overview)
    imageshack.com/a/img922/8052/wFOJyT.jpg (overview)
    imageshack.com/a/img922/1108/gcyagN.jpg (code)
    Can you tell me what I do wrong?

    • @ArduinoLegoTrains
      @ArduinoLegoTrains  8 років тому

      +Niels Albrechts Hi! Your code looks identical to mine. Have you opened the Serial Monitor and confirmed that your sensor reads below 500 when the train is detected?

    • @NielsAL1988
      @NielsAL1988 8 років тому

      Hi!
      Yes I have opened the serial monitor and there are no data in the monitor but the green light in the sensor switches on and off correctly

    • @NielsAL1988
      @NielsAL1988 8 років тому

      Sorry, there is data in the serial monitor, but only 0.

    • @ArduinoLegoTrains
      @ArduinoLegoTrains  8 років тому

      Niels Albrechts
      Something's not right there. Send this little sketch to your arduino:
      int LDR = 0; //analogue input pin
      int LDRValue = 0;
      void setup() {
      Serial.begin(9600); }
      void loop() {
      LDRValue = analogRead(LDR);
      Serial.println(LDRValue);
      delay(100); }
      Connect the light sensor, and make sure you have readings between 0 and 1023. If you only have 0, then you have not connected the light sensor correctly (i.e wrong analog input pin, wrong wires, no power etc).

    • @NielsAL1988
      @NielsAL1988 8 років тому

      +Arduino Lego Trains
      That tests works correctly. Normally the serial monitor gives a value between 27 and 31. When the sensor detect my finger the serial monitor gives a value of 1023.

  • @chrisdub8883
    @chrisdub8883 7 років тому

    Haha, gold!

  • @steinlaus5605
    @steinlaus5605 3 роки тому

    Why does nobody care about the accident? With the CAT?! I wanted this cat so bad when I was a kid!
    So moral of this video: You need to spot your cat, use ultrasonic or so cause other times it's bad! :) Meow.

  • @LordPhobos6502
    @LordPhobos6502 4 роки тому

    Video start reminds me of: ua-cam.com/video/IJNR2EpS0jw/v-deo.html

  • @FARIS__KHAN
    @FARIS__KHAN 8 років тому

    any idea how could i use the light sensor as an anti collision?

    • @ArduinoLegoTrains
      @ArduinoLegoTrains  8 років тому

      Sure! Check out tutorial #6

    • @FARIS__KHAN
      @FARIS__KHAN 8 років тому

      I have trouble implementing the sensor infront of the train to make it stop when there is an obstacle.i need help:(using infared sensor

    • @ArduinoLegoTrains
      @ArduinoLegoTrains  8 років тому

      For infrared sensors you need two LEDs; an infrared LED and an infrared sensor (photoresistor). I used these in Tutorial 8 (ua-cam.com/video/JKjcNlPMSNc/v-deo.html), so check out the code there.