//
you're reading...

Lego

Lego and the Arduino Microcontroller

In the 10 years of Lego robotics, it has come a long way.  From the original RCX to the modern NXT, the things that can be created from these kit have become, far more advanced. Creating everything from walking robots to Great Ball Contraptions, people have created some amazing things, but what happens when people want to create beyond the limitations of the Lego Mindstorms?

When users hacked the original Mindstorms RCX, Lego embraced the hacker mentality and allowed them deeper access to hack the second generation NXT processor and worked with third party sensor developers to allow the expansion of Mindstorms beyond the original visions of the Lego developers.  Sometimes, that isn’t enough and the creations can be expanding by forgoing the Mindstorms and embracing open source hardware, like the Arduino.

The Arduino is a form of open source hardware, where the Arduino is built and sold, but the schematics are freely published as well, so that anyone interested can build their own from scratch, if they are so inclined.  This has led to the creation of different sizes or independent creations, like the Freeduino.  The Mindstorms NXT brick is rather large and not conducive to small projects, but the Arduino Nano is a small board that at 1″ x 2″ can be embedded into much smaller projects.

The Arduino has more flexibility than the NXT.  With 3 motor ports and 4 sensor ports, the NXT limits you to the number of connections, plus you are limited to the available sensors.  Third party companies, like Hi Technic, expand on the available sensors, but the Arduino gives ground level access to the sensors.  By having 20 input and output ports on the standard Arduino (and more on the Mega), you plug the sensors, motors, etc. directly into the processor and have direct access to them via the code. With a breadboard, the only limitation is the way the different ports are configured for input and output access.

With the usage of open source, the Arduino uses a variation of the C/C++ language that is able to directly address hardware via the language. For more in depth usage, libraries can easily be written or downloaded from sites online to expand the usage of the programs.  By using C based notation, the learning curve is simple for most programmers.

Thanks to the opening of the NXT hardware, there is a variant of C available for Mindstorms, but requires the knowledge to flash the firmware to replace the language.  Since the Arduino is also open, it gives similar opportunities to use alternate firmware to program it.  This gives birth to programs such as the Netduino, a variant of Microsoft’s .Net that can be used to communicate with the Arduino hardware.

Programs for the Arduino in its native language have two required parts, the setup and the loop.  The setup is where variables are setup, serial communications are opened and other functionality is prepared.  The main processing is done in the area defined as the loop.  Once the program is executed and the setup is processed, the loop continuously runs, and the processing within the loop via inputs, outputs, conditionals and data processing.  As each loop iterates, it evaluates the conditions and reacts accordingly.  For example, the code to the right initializes port 13 to be an output then alternates the power between high and low to cause an LED to blink at a regular interval the entire time the code is running.

The strongest addition to the Arduino are boards that connect to the microcontroller that are referred to as shields.  They are often shipped as a bag of parts that require soldering skills to assemble.  A user of one of these skills not only learns about soldering skills, but about the different parts that go into electronic devices.  Many of the directions explain what things like transistors and capacitors are, how they work and how they need to be used in order to work properly. For instance, an LED will only work with electricity going through it in one direction to light up while a resistor can be inserted in either direction and still regulate the volage passing through it.  Once the shields are built, they snap on top of the main Arduino and expand the capabilities of the Arduino to give it communications, sound, motors and other features that can be added on.

The one thing that the NXT can do that the Arduino can’t is to integrate with a Lego structure easily.  While the Mindstorms brick with the processor has technic holes on the side, the Arduino hardware has no such convenience.  The Arduino processor most either go in a Lego brick enclosure or use an adhesive (the bane of most Lego builders) to keep it in place.  When planning a Lego sculpture that integrates Arduino, it’s important to keep processor placement in mind, including any shields, wiring and other add-ons used by the project.

The greatest feature that the Arduino has that cannot be matched by NXT is the level of communication Arduino can provide.  The NXT allows you to connect to a PC or Mac via USB or to send messages to the PC, another Arduino or a cell phone via USB, but the Arduino can reach out far beyond that.  Thanks to available shields and its open architecture, the Arduino can use the USB, Bluetooth, Ethernet, Wifi, XBee and more.  This allows the Arduino to not just communicate with the devices around it, but to reach out directly to the internet to email, Twitter, send SMS, and any other potential ideas that you may have without a go between like a PC or cell phone.

Arduino brings a new aspect to Lego that would not have been possible otherwise.  While it is not a replacement to all Mindstorms projects, it gives new possibilities thanks to it’s size, features and flexibility and can be used instead of or in conjunction with Mindstorms to create whole new experiences.

Be Sociable, Share!

My Etsy Store