Lego powerfunctions library

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.

http://www.rjw.speedxs.nl/arduino/LEGOPowerFunctions.rar

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

I have made a update, removing some bugs. I've also made a joystick from it.

http://www.rjw.speedxs.nl/arduino/front.jpg http://www.rjw.speedxs.nl/arduino/print.jpg http://www.rjw.speedxs.nl/arduino/inside.jpg 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.

Hi,

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.

Thanks.

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

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!