Control Lego Power Functions via IR remote and blockly
-
Hey!
I wanted to let my son experiment a bit with M5Stack and Lego. I've seen that there is a module to control Lego motors, but this seems to be rather for mindstorms motors (EV3 or NXT seem to be the notations). However, many cheaper Lego models come with Lego 'Power Functions' motors, which won't work with this module for all I can tell.
I was thinking through different options, and finally felt like the easiest way is to just emulate the IR remote with M5Stack, which in theory would be pretty straightfoward to do. There are even some libraries to do so, but none seems to be compatible to UIFLow blockly, which my son would use:
https://www.elecfreaks.com/store/blog/lego-power-functions-ir-sender-for-microbit.html
https://github.com/jurriaan/Arduino-PowerFunctionsIs there any good way to import these into UIFlow blockly to use for an 8 year old?
Might it be an option to integrate this by default into UIFlow, as it is a cool option for many users.Regards,
Freefaller -
Hi @Freefaller you can take a look at this thread for info about using older lego motors http://forum.m5stack.com/topic/1570/is-there-an-easy-way-to-connect-m5stack-or-m5stick-c-to-old-lego-mindstorms-motors-and-sensors-robotic-invention/15 also @ajb2k3 is quite knowledgeable on this subject and usually quite happy to respond to any questions
-
Oh wow, sorry for missing this existing thread. Not exactly what I was looking for (as I was hoping for the infrared connection) but still what I need to solve my problem. Will probably then get the base-x module and solder myself the cable connections (can't seem to be able to buy them anywhere anymore).
Thanks! -
Sorry been absent for a while.
Someone did control PF using the stick C's built in IRLED but can't remember how.
There are instructions on how to build NXT>PF leads but I haven't had time to revisit. -
Someone did control PF using the stick C's built in IRLED but can't remember how.
So there's existing integration for that into MakeCode (which is also blockly based I believe) and then also the regular Arduino lib. Also the whole IR protocol is documented officially by Lego. But the MakeCode integration seems JS based (not Python based), and I also don't see a good waqy to integrate the Arduino lib into the UiFlow custom component editor. So probably whoever did this before just wrote regular Arduino code for the M5Stick using the Arduino library.
If I ever find a lot of time I might try to reverse engineer the existing code, and redo as a custom block in UIFlow, but not sure if this will ever happen ;-)
There are instructions on how to build NXT>PF leads but I haven't had time to revisit.
I'm also gonna look into that :-)
-
@freefaller the front end of UIFlow may be java but the back end code that gets sent to the M5Stack is Micropython