Lego Tracksections

And we are back for the next level! It’s time to divide up the track in sections so we can have a couple trains driving around. I found the blog at really interesting because it makes use of photosensors. I used microswitches, but they tend not to work really well with a carpet and everything, so I started using LDR’s instead. The result looks a bit likes this:

IMG_3028 IMG_3027 IMG_3026

I used a couple little prints to put the LDR’s on with a 10k Ohm resistor as voltage divider. This works pretty much ok. In the last picture you can see the first attempt of the setup. In the meantime I changed it a little bit, but not too much. The “railplan” looks like this at this point:


In short, this is what happens so far:

1. Get the sensor reading

2. Determine the previous sensor (so you know which way your train is going)

3. Set the correct flags so we can call a function to get the trains up and running (e.g. what section will the train in be next?)

4. The function to get the trains running checks for some things. Of course we need to know if the next section to where the train is going will be busy or not. This can later be used to set switches and signposts!

As of this evening the sensors started acting up, but my detection mechanism worked flawlessly. It gives the current position, train number and next section via the Arduino Serial Monitor.

Ah well, more to fiddle around with! Catch you later!

Leave a Reply