Richfilth

Controlling 9V trains with Arduino

Recommended Posts

I've just purchased a raspberry PI after seeing plenty of automation projects.

As I have never heard of Arduino, could this also be possible to replicated with the Raspberry?

i suspect the need for a power converter to produce 9v-12v.

Share this post


Link to post
Share on other sites

You can probably do some of the basic things, but a Raspberry Pi isn't really an input/output board, so you will still need to buy some interface boards to connect sensors and control the motor controllers (since the Pi doesn't have PWM capabilities).

So really you need an Arduino-equivalent too, but you can connect it to the Pi so that they work together: they're not mutually exclusive.

Share this post


Link to post
Share on other sites

You can use the PiFace Digital extension for the Pi, it has 8 outputs and 8 inputs. The outputs are open-colector darlingtons, can drive most LEGO motors but just one direction. Two of those outputs are also relays so you can drive one LEGO motor both-directions with 2 outputs. Or you can add H-bridge modules to drive up to 4 motors (each H-bridge uses two outputs).

The inputs can be connected to LEGO 9v touch sensors or PF switches. 4 of the inputs are also connected to tactile buttons.

You can use software interrupts or just carefull timings as an alternative to the lack of PWM in the Pi.

Here a configuration I used one year ago, using just one motor (but could use 2, it's a dual H-bridge board).

pitagoras-e-a-esfinge.jpg

I like the PiFace Digital because it isn't intended for any particular purpose but there are also extensions intended for motor control with H-bridges included like the RasPi Robot Board v2 by MonkMakes.

Edited by MajorAlvega

Share this post


Link to post
Share on other sites

Not sure if anyone's still interested :laugh: But here's the tutorial for Ultrasonic-managed Sidings:

Edited by Richfilth

Share this post


Link to post
Share on other sites

Anyone apply this stuff to the new style Lego remote control(Power Functions) as used currently?

Always look for projects I can teach my boy.

Share this post


Link to post
Share on other sites

Yes, I'm still interested :D

Because of your videos I want to buy an Arduino myself.

Dave

Edited by Dave21

Share this post


Link to post
Share on other sites

Yes, I'm still interested :D

Because of your videos I want to buy me a Arduino myself.

Dave

What He said! I'm in myself :thumbup:

Share this post


Link to post
Share on other sites

Yes, I'm still interested :D

Because of your videos I want to buy an Arduino myself.

Dave

What He said! I'm in myself :thumbup:

Same here, I'm still waiting for all of his video to understand more about Arduino programming before jumping into it!

Share this post


Link to post
Share on other sites

Anyone apply this stuff to the new style Lego remote control(Power Functions) as used currently?

Always look for projects I can teach my boy.

There is arduino code that generates the PF infrared codes, and you need an IR LED to blast it out. I've done it and I know there's posts around talking about it, but my setup is crude and I haven't worked on it in ages. But yes, it is possible.

What's the difference between the Raspberry Pi and Arduino? Would they both work for these sort of things?

They're both small programmable boards, but they're completely different. It's like mac vs pc. I'm sure you could run a train from a Pi, but I've never used a Pi. The Pi is definitely more powerful, but I don't know how it does with simple things like this.

Share this post


Link to post
Share on other sites

They're both small programmable boards, but they're completely different. It's like mac vs pc. I'm sure you could run a train from a Pi, but I've never used a Pi. The Pi is definitely more powerful, but I don't know how it does with simple things like this.

Ok. I've heard varying opinions about them. It does seem that the Pi is more powerful though (there's even a version of Minecraft for it, believe it or not).

Thanks for the clarification.

.

Share this post


Link to post
Share on other sites

Thanks for all the support guys :sweet: It's much appreciated!

I'm still waiting for all of his video to understand more about Arduino programming before jumping into it!

Don't wait! You only really learn this stuff by playing around with it. Also, it takes me so long to make each video that I have no time to work with the Arduino, so I don't know when "all" of the videos will be made :)

Anyone apply this stuff to the new style Lego remote control(Power Functions) as used currently?

I will be covering Infrared LEDs and phototransistors in future videos, which is how the Power Functions systems work - however, I don't know how to control one directly since I don't have any PF stuff. But if someone wants to donate a PF remote... :laugh:

What's the difference between the Raspberry Pi and Arduino? Would they both work for these sort of things?

It's already been answered once in this thread :classic: The Pi isn't really an input/output controller, it's more of a general computer for running software (like media file centres etc). The arduino is specifically built to read sensors and power physical switches like lights, relays and motors. You can do this sort of stuff with a Pi, but it's more expensive and more complex - you don't need 1Gb of RAM to drive a lego train forwards and backwards. :laugh:

Share this post


Link to post
Share on other sites

Where is the "like" :thumbup: button for these videos!!!

Top quality, keep up the good work.

Share this post


Link to post
Share on other sites

Here's the latest vid in the series: Controlling your junctions/crossings with an Arduino.

Edited by Richfilth

Share this post


Link to post
Share on other sites

Really nice tutorial, you give me a lot of idea, ok is not lego part, but if lego don't do something like that meanwhile i use Arduino

Now i'm out of Italy and i can't play with arduino(i just order),

I have one question about the electronic Parts, there is something to control one motor and maybe one sensor, wirless?

For understand very well my question, i need a motor and one sensor on a moveable part, so i can't connect it with wire, there is some component to made it?

I hope to explain it in a good english, thanks!

Share this post


Link to post
Share on other sites

I have one question about the electronic Parts, there is something to control one motor and maybe one sensor, wirless?

For understand very well my question, i need a motor and one sensor on a moveable part, so i can't connect it with wire, there is some component to made it?

You can't have a wireless motor (they need power :D), but you CAN get an Arduino Nano. This very small arduino can be located next to your motor/sensor so that your machine is "independent" - it does not need long cables to anything. But you must always think how you will power these machines - a motor needs a lot of batteries, unfortunately.

Share this post


Link to post
Share on other sites

You can't have a wireless motor (they need power :D), but you CAN get an Arduino Nano. This very small arduino can be located next to your motor/sensor so that your machine is "independent" - it does not need long cables to anything. But you must always think how you will power these machines - a motor needs a lot of batteries, unfortunately.

You get the point, my proget is a stand alone, but made short movement, like a switch, but is no possible to have the cable from Computer to my project.

so i can insert a 9 volt battery, the arduino Nano, and a motor( we can use your switch like example).

the Arduino Nano, is possible to program or control via wireless with computer or mobile, or need the arduino connected to computer and wireles control the arduino nano?

And what is the best program for Iphone to control Arduino?( remember, i'm not going off topic, my project is about Lego train!)

Thanks for your attention!

Share this post


Link to post
Share on other sites

ALL arduinos can run without a cable to the computer - that is what Arduino is designed to do. You only connect them with a cable when you want to program them, but after you write your program and send it to the Arduino, you can remove the cable. I only have the cable in my videos to supply 5V power.

Some people add a Bluetooth module to their Arduino so that they can read the sensor inputs and control motors - a simple HC05 Bluetooth module is all you need for this. Some people have connected an arduino with wifi and were able to program it, but I don't have any experience with that.

Share this post


Link to post
Share on other sites

Hi again! This latest video demonstrates how to decode an infrared (IR) remote control, and how to use those codes to control your 9V trains! Enjoy!

Share this post


Link to post
Share on other sites

Hey Lego fans! It's been a long while, but I finally made another video. A simple concept - LEDS - but used to do something cool; two trains on one loop, in opposite directions :D Hope you like it!

Share this post


Link to post
Share on other sites

Hey Lego fans! It's been a long while, but I finally made another video. A simple concept - LEDS - but used to do something cool; two trains on one loop, in opposite directions :D Hope you like it!

great job! was wondering where have you been. looking forward to your next video!

Edited by toxicbananna

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.