SparkFun Forums 

Where electronics enthusiasts find answers.

User avatar
By wagonracr
My Daughter and I are looking to get a "Red Board" (Arduino) to do some Lego Projects with. She is in the coding club at her Elementary School. She did a Lego Boost project last year. We wanna step it up a notch.

First question, she has done some "Scratch" coding. Can a Red Board be coded with the "Scratch" programming environment?

Next Question, what would be a motor driver to get for Lego L Motor?

We are "Noobies" so tips, tricks, and hints, will be very appreciated.
Mike & Emily
User avatar
By TS-Mark
Hi Mike & Emily,

As far as I know, I do not believe the Arduino Uno or the SparkFun RedBoard can be programmed with Scratch. I did find a user-created Scratch modification called S4A that claims to allow for programming Arduino hardware with Scratch but we have not tested it to verify it works well. Also, I am not sure if there will be code support in that add-on that will allow for using a DC Motor driver from our DC Motor Driver Category. I am not sure if any of our motor drivers would work with a Lego motor as we do not have any to test but most likely, something like the SparkFun Motor Driver - Dual TB6612FNG (with headers) would be able to drive that motor. Our Hookup Guide will go over the basics of that motor as well as an example circuit with demo code to get started.

Another option for a node-based code system similar to Scratch would be the BBC micro:bit. We have a motor driver carrier board, the SparkFun moto:bit, that connects to the micro:bit to add the ability to drive DC motors and other peripherals. We have an Experiment Guide that will go over the board's hardware as well as the make:code add-on to code the micro:bit. If you are interested in learning more about the micro:bit, I would recommend taking a look at our micro:bit Landing Page.

One last thing that might help provide some inspiration for your project. Recently, a member of our tutorials team built a micro:bit-powered Wall-E LEGO Robot. This blog post goes into some of the parts and by adapting the example code from this tutorial, they were able to get this Wall-E "robot" moving.

I hope this information is not too overwhelming and gives you some options on where to get started with your project. Let us know if you have any further questions about these products or tutorials and we would be happy to help as much as we can.
User avatar
By wagonracr
Thank You, Mark.
I have tested the Lego L Motor with TB6612FNG Driver and it went well. I purchased a Proto Shield Kit to make this part of the project permanent.
I have seen the S4A and downloaded a copy to look at. I'm not sure I want to try loading the firmware on my RedBoard yet. Need to see how to load back the Arduino Firmware in case its a disaster.
I'm currently in the search to see if anybody has hacked a Lego Powered Up Color and Distance Sensor and made it usable with a Arduino.
User avatar
By TS-Mark
Hi again wagonracr,

That's great to hear the TB6612FNG works well with the Lego L Motor! I understand your apprehension using the S4A modification but as far as I can tell the "firmware" they instruct you to install on the Arduino is just a standard .ino sketch that will only live in the program space of the RedBoard so you should be able to overwrite it by uploading new code like the standard "Blink" example. It shouldn't corrupt the bootloader or anything else vital since that lives in protected memory. If you do somehow manage to get the RedBoard into an unknown/"bricked" state and somehow corrupt the bootloader, you can recover it by re-flashing it either with a programmer or another Arduino like this tutorial demonstrates.

One other thing I forgot to mention in my first post. There is a nifty but a little more complex node-based programming language that works great with Arduino called XOD. It is similar to Scratch but is a bit of a deeper dive in terms of understanding how the code interacts between the microcontroller and the peripheral component whether it be a temperature sensor, an LDC or an LED. They have some great tutorials to get you started but it is a bit cumbersome. I have used it personally with a RedBoard and our Digital Sandbox kit and it works great as a node-based-programming platform once you get used to it. It currently should work with most Arduinos and other peripheral hardware and is updated pretty frequently.