Go Down

Topic: Lego powerfunctions library (Read 4062 times) previous topic - next topic


I've made a library to control the lego powerfunctions receivers.
Its using IR so you only need a arduino and a IR led.
A nice extra is you can do PWM control on the motors, the lego RC cant do that.

There is an example included with a program that emulates the RC from lego.


Bare in mind, this is my first library so if you have suggestions, better code optimization tell me :)


Apr 24, 2009, 12:52 pm Last Edit: Apr 24, 2009, 01:40 pm by SuperCow Reason: 1
I have made a update, removing some bugs.
I've also made a joystick from it.

schema: http://www.rjw.speedxs.nl/arduino/arduino-joystick.bmp

To make the IR pulse i used the function: oscillationWrite from David Cuartielles
with a delay of 13us should make 38khz frequent.
But this is not the case, I've put it on a scope, and its about 28khz.
So i have lowered the timing to 9us.



Tried your library and it worked on the first run. A few questions though, why didn't you use a timer to generate the signals for the IR-Led?
And could you give some comments on the LEGOPowerFunctions::message_pause, I don't understand where the calculations are for.



This is a nice one!!! Thanks a lot, it will be great to control LEGO PF Trains etc.


Mar 15, 2010, 12:46 pm Last Edit: Mar 15, 2010, 02:24 pm by amacmullen14 Reason: 1
Cool!  I ordered one of those speed control remotes, but it's backorded till next month.  (just the estimate, probably will come earlier)
Even when I recieve it, I could still use the arduino.

Mindstorms cheap replacement?

Edit:  Just got it working to power remotely my EPD.  (Entirely pointless device)
It is a small device that fits on a desktop.  The powerfunctions battery powers 2 XL motors, which turn cranks, which pump lego pneumatic pumps, which activate lego pneumatic cylinders, which switch their own valves, moving up and down repeadedly.  It's a completely inefficient and convoluted way to get two rotating reciprocating motions from one device!
Now I just have to have the cylinders reverse the direction of the motors, making a huge cycle of pointlessness!

Go Up