How to control Lego motors and servos with Arduino

Thread Starter

rincon

Joined Aug 15, 2018
2
hello dear arduino-experts

i want to take a Lego-Car (only a basic - chassis like here: https://www.instructables.com/id/Build-your-own-Custom-Arduino-Remote-Control-and-L/ )

The aim is to control Lego buildings from Arduino boards with low cost parts. This first projet where i do not want to adapt the traditional servo-motor 9g to plug it with Lego blocks. I want to stick with the Lego Power-functrions.
in other words: For this project i do not want to make use of the low cose parts: i.e. the servo-motor 9g

i want to take Control Over the Lego Power Functions and the so called Lego Technic Servo Motor.

the question is: how to control Lego motors and servos with Arduino


some musings:
- Lego has a 4 cable connector. Two of them supply power (+9V & GND) and the other are optionally +9V and they are called C1 and C2.
- the Servo turns in some directions: eg right or left max 90 deg when we supply PWM to either C1 ("left") or C2 ("right"). (or the other way round - in other words left and right and viceversa)

That basically means that what I need is a 9V PWM and be able to supply it to either C1 or C2.
What is more the frequency has to be 1150 Hz.

Now the question is how do I achieve this goal? i have heard about using the L298N motor-controller:
The A L298 dual H-Bridge motor control module for Arduino - this can help here to get connected to wired control LEGO Power Functions Motor. With this Arduino can control LEGO Power Functions Motor to forward, backward, and besides this also in the so called float, brake, PWM variable speed, and lots of other things more.


how to controll the Lego-Power functions: Well i guess that i have have few options, with different precision and complexity:

1. i can do this with some configurations one of the PWM HW blocks
2. i can make usage of a timer to trigger a sw function - but it might be simpler to just configure the Pulse wiede Modulation HW block.
3. i can make usage of some existing legacy library that will implement one of the above mentioned methods


the question: which method would you recommend


i am willing to learn something of the AVR internals and it will be the solution with the least overhead.
are there some tutorial.

besides this: is there a brick that i can use here?

i have heard bout a brick: see: https://www.eurobricks.com/forum/index.php?/forums/topic/152982-brick-to-connect-pf-motor-to-arduino-board/

do you recommend this brick - do you think that this is useful!?
[/quote][quote author=apollodriver link=msg=4026475 date=1548020133]
hello dear arduino-experts

i want to take a Lego-Car (only a basic - chassis like here: https://www.instructables.com/id/Build-your-own-Custom-Arduino-Remote-Control-and-L/ )

The aim is to control Lego buildings from Arduino boards with low cost parts. This first projet where i do not want to adapt the traditional servo-motor 9g to plug it with Lego blocks. I want to stick with the Lego Power-functrions.
in other words: For this project i do not want to make use of the low cose parts: i.e. the servo-motor 9g

i want to take Control Over the Lego Power Functions and the so called Lego Technic Servo Motor.

the question is: how to control Lego motors and servos with Arduino


some musings:
- Lego has a 4 cable connector. Two of them supply power (+9V & GND) and the other are optionally +9V and they are called C1 and C2.
- the Servo turns in some directions: eg right or left max 90 deg when we supply PWM to either C1 ("left") or C2 ("right"). (or the other way round - in other words left and right and viceversa)

That basically means that what I need is a 9V PWM and be able to supply it to either C1 or C2.
What is more the frequency has to be 1150 Hz.

Now the question is how do I achieve this goal? i have heard about using the L298N motor-controller:
The A L298 dual H-Bridge motor control module for Arduino - this can help here to get connected to wired control LEGO Power Functions Motor. With this Arduino can control LEGO Power Functions Motor to forward, backward, and besides this also in the so called float, brake, PWM variable speed, and lots of other things more.


how to controll the Lego-Power functions: Well i guess that i have have few options, with different precision and complexity:

1. i can do this with some configurations one of the PWM HW blocks
2. i can make usage of a timer to trigger a sw function - but it might be simpler to just configure the Pulse wiede Modulation HW block.
3. i can make usage of some existing legacy library that will implement one of the above mentioned methods


the question: which method would you recommend


i am willing to learn something of the AVR internals and it will be the solution with the least overhead.
are there some tutorial.

besides this: is there a brick that i can use here?

i have heard bout a brick: see: https://www.eurobricks.com/forum/index.php?/forums/topic/152982-brick-to-connect-pf-motor-to-arduino-board/

do you recommend this brick - do you think that this is useful!?
 
Top