BrickPi - Rainbow Unicorn

by stoeltje in Circuits > Raspberry Pi

1600 Views, 1 Favorites, 0 Comments

BrickPi - Rainbow Unicorn

20200808_205241.jpg
20200804_082459.jpg
20200808 205248

Enter the Time of Covid and Shelter-in-Place teaching and no summer camp (best part of the teaching year!) I have a Friday Lego "Club", with mostly 8-10 year old boys. Since this club occurs in after-school after these kids have been in school/after-school for 50 hours a weeks, the Lego projects have to be pretty straight forward and many of the projects I can find on the web have HUGE potential, but nothing most of the kids could work thru. As I am always busy, there is never any time to just play with these Lego projects...but this summer was different. I found these Trotbots on DIYWalkers.com that look amazingly like a galloping horse! Add in the Rainbow Contest, and of course, it had to be a rainbow unicorn!

The unicorn horn part was made possible by the BrickPi by Dexter Industries. The BrickPi combines a Lego Mindstorm compatible "hat" over a Raspberry Pi so that you can plug in the Lego motors and sensors and create a robot. You can also use Scratch (and Python) to program your robot which is a great plus for kids. I have been trying to set up a set of building plans for my kids to use with the BrickPi, similar to the instructions in NXTPrograms.com.

The rainbow unicorn horn uses the GPIO pins that pass through from the Raspberry Pi to the Brick Pi. I had some problems with one of the pass through pins, Nicole from Dexter Industries helped SO much! And thus the Rainbow Unicorn was born. (I may try to make a Rainbow Unicorn Pegasus!)

Supplies

LEGO MINDSTORMS Education NXT Base Set (9797)

LEGO MINDSTORMS Education Resource Set (9695)

An extra Lego Mindstorms Ultrasonic sensor

Either:

  • Brickpi Starter Kit, which includes a Rasberry Pi, temperature, humidity and pressure sensor, although you may need to purchase more cables to run your RPi alone
  • OR
  • BrickPi3 Base kit PLUS
  • Make sure you have the 8 battery pack that's included with the BrickPi. I'm not sure you can replace it with one from Amazon

SHORT heat sinks, 1 each, about 1/2" and 1/4" (may be included in RPi link above) They MUST be the shorter ones or they interfere with the BrickPi

HDMI Monitor

Wireless mini keyboard and touch pad

Anode RGB LED

4 jumper wires - I used 4, cut off one end and used only the female end, soldering the other

M2 standoffs - I used 7 15mm standoffs with the appropriate nuts and screws

Pipe cleaners or something to make the mane and tail

Rotary Drill

Nice to have

Full sized keyboard and mouse - MUCH easier to program with

Universal AC adapter - to cut down on batteries needed to program your truck

Glitter Nail Polish!

Set Up the BrickPi With the Raspberry Pi

2020-06-18_0001.jpg
2020-06-18_0002.jpg

Fot the basic setup, I'm going to send you to the websites that describe their setup because they are much clearer than I could make as well as just being redundant.

Note: To run the BrickPi, you will need to use the Raspian for Robots image that is on their site, so you'll either need a separate 8G minimum SD card or at some point you will have to write over your raspberry pi card. So, before you install Raspian onto your SD card as instructed in the "Basic Raspberry Pi setup" below, you could install Raspian for Robots onto your SD card. It is an older version of Raspian than what's on the raspberrypi.org web site, but most of the functionality is there. Then just skip the Raspian loading part of the Basic RPi setup.

Basic Raspberry Pi setup according to raspberrypi.org.

Before we go on to the BrickPi setup, we need to add some things that we will need because the BrickPi closes the RPi in and you can't get to it without taking it apart

Heatsinks The RPi doesn't come with heat sinks installed. The Image to the left shows without heatsinks and the image to the right shows where to place the heatsinks.

Brick Pi Setup and Notes on the GPIO Pins

Basic BrickPi setup for later use if you choose!

Note: if you are going to use the BrickPi as is, I suggest placing it in the clear plastic enclosure that comes with it. I am not completely happy with the case as it isn't very fun nor is it easy to attach to the robot as the holes are not made quite right: they don't taper as the lego beam holes do. But it does work and it will protect. However, for this project we are going to use Lego cases made for the RPi and modified. We do that in the next step.

For a rundown of the header usage, see Dexter Industries Forum on which GPIO pins can be used.

I have put my observances in The Useable BrickPi GPIO pins pdf file attached to this instructable.

Add Your 2x7 14-pin Right Angle Female Header (optional) and the BrickPi

2020-06-18_0004.jpg
2020-06-18_0005.jpg
2020-06-18_0006.jpg
2020-06-18_0009.jpg

The pins on the Raspberry PI, below the Brickpi board that are not being used, can be used for other things, but they are so close to the upper board that it's difficult to insert jumper cables. I used the 2x7 right angle female header to make them available. For this project, I have not used this header. I only used the upper headers on the BrickPi board as you will see in later sections.

But ALL of these headers are available for use, unlike the upper headers off the BrickPi board, some of which are completely off limits, some of which are only used at certain times. There are 3 things to take care of: The 2x7 right angle headers I found are too big to fit with the BrickPi header. I had to use my rotary tool with the sander band to grind it down to fit, see the first picture. It was VERY tight - as seen by the fact that the metal tines show through. (2nd picture). With enough grinding, the BrickPi header will fit (3rd picture). Also, as you can see from the 3rd picture, the S2 port is immediately above the 2x7 right angle pins. Don’t let the metal pins touch the metal portions of the port. If you push the 2x7 pins down ALL the way, the USB ports hold the BrickPi board up high enough that the pins do not touch any metal pieces, but I put electrical tape on anyway. I don’t know how long it will last. Last, the headers and the motor and sensor ports keep the BrickPi - RPi spacing on 3 sides, but considering my target audience (8 year old boys) I added a standoff in the corner to the right of the SD card. (4th picture)

Set the BrickPi Into a Lego Case

2020-06-18_0012.jpg
2020-06-18_0013.jpg
2020-06-18_0014.jpg
2020-06-18_0015.jpg
2020-06-18_0016.jpg
2020-06-18_0017.jpg
2020-06-18_0019.jpg
BrickPi3-Port-Layout-1-1.png

I purchased this Lego case in yellow. The bottom part of it fit beautifully, while I had to cut away parts of the top with the rotary drill so that the BrickPi ports could be used. I like this yellow case because it holds the Brick Pi securely.

I fit the RPi into the bottom of the case. It was a good fit and snug. Now we have to cut part of the casing away so that we can fit the BrickPi into it. Slip the side that should encase the USB ports down over the BrickPi Motor Ports and look at the other end. Mark where you will make your cut over the power plug. Then cut. Now you have to mark and cut each of the other sides:

  • over the GPIO pins and the ports on that side
  • over the 2 Motor Ports above the USB ports
  • over the remaining ports on the last side.

Last, we have to mark and drill holes for the M2 standoffs.

You might also want to mark the ports so that you know which is which!

Make Your Lego Creation

To create my BrickPi Unicorn, I used most of the instructions for the Hexapot Trotbot as shown in www.diywalkers.com. This site is well worth looking through. Their walkers are AMAZING!

I did change some of the instructions for use with my kids and so as not to use the metal rods which my Lego sets, of course, do not have. I am going to give you the original links but include, in this instructable, a pdf of the steps I took.

Torso and Motor

2020-08-12_0016 (2).jpg
2020-08-12_0015 (2).jpg

As stated above, I used the Hexabot Trotbot build. See the TorsoSides.pdf for the general instructions. You must make 2 torso sides, mirror images of each other. The cranks are show in the CranksForLegs.pdf. The Hexapod Walker we are copying only has one torso frame and uses a different motor, but A) I didn't want the unicorn that wide and B) (and let's get real: this is the real reason) I didn't have one of those motors.

Note: I had a limited number of beams, a lot of my beams are still at school on kid-built robots, not put away because of the quick school closures, and, despite 5 NXT education kits, this build uses a LOT of beams. Also, the studless beams, which i\the Trotbot instructions call for are mostly greys. My colored beams are the older studded beams. So I used mostly studded beams, as many colored as I could for the "rainbow" effect, except where the fit was so close I had to use studless. See image for how I used the studded beams.

Because I had a limited number of studless beams and the legs really needed all I had, I used a lot of studded beams. Also, they added color. There were only a few that had to be studless to fit into tight spots. Finally, the studded beams at the top are necessary so that you can build up over the motor to make a platform for the BrickPi.

Another difference is that I used Lego axles, not metal rods as show in the last photo. The axle is an 8 with a stop on the end. There is plenty of room to use a reglular 10 beam with a bushing at the end. Look at the next page to see how to attach the motor.

The Motor

The motor connects as shown to the MIDDLE TOP of the torso, although I've turned everything upside down so you could see how it lines up. To finish, you will have to hold it in place by placing 2 studded beams on the top beam of the torso and threading a long axle through them and the motor mounts. You will probably have to move this around when you get to adding the BrickPi.

Legs

2020-08-12_0010.jpg
2020-08-12_0014 (2)_LI.jpg
2020-08-12_0005.jpg
2020-08-12_0006.jpg
2020-08-12_0004.jpg
2020-08-12_0001 (2)_LI.jpg

See the SimplifiedLegs.pdf to build the legs. You must make 4 of these, 2 sets of mirror images as I have shown in the image of the 4 finished legs above. (Blurry again, sorry.)

Note that I modified the legs a bit:

  • I put in colorful studded beams at the top as shown in keeping with the Rainbow aspect of my creation.
  • The original build called for cutting studless beams to make a studless 6-beam and 8-beam for each leg. Rather than that, for the 6-beam I used a bent studless beam with one 6-holed side. For the 8-beam, I just put the connector in the 8th hole of a 9 hole beam.
  • Because I was constrained by the number of Lego pieces I had in my kits, I did not have enough "D" ring pieces for the cranks.But all I needed was a 5-ring piece with axle connections on the ends and the little coat-hanger looking pieces work beautifully.

The cranks need a bit of explanation. The 2 images of the sides of the Torso show the different angled settings of the cranks.The 2 "coat-hangers" are in the front asnd the 2 "Ds" are in the back. The image showing both the torso and 2 legs indicate how to connect the legs tot he cranks: The top side of the legs are at the bottom of the picture and the 2 grey axles sticking up will be inserted into the free end of the 5-side of the cranks. The photo showing from the top of the torso shows how you attach the top of the leg to the torso: you will push the extended axle through the 3rd hole from the end of the 2 top beams.

Downloads

Add BrickPi, It's Support Bricks, Test Bracing and Motor Test

2020-08-10_0007.jpg
Test_1_motor.gif

Now you can add the BrickPi and see if the legs work!

First you have to create a platform for the BrickPi as seen in the PDF attached. Lego files are traditionally show in this manner. And this instructable would be hundreds of instructions long without the PDF files!

I always test on raised bracing so that the robot doesn't run away from me, fall off the table and break! See the image.See the image with the black supporting Legos on the box.

Now that your body and legs are set up, plug a wire into motor and motor port A (if you are going to use my Scratch files) and write the code to test just one motor. This code will test any motor port you have a motor attached to. The final code is set up to run the motor off of motor port A. You can input "a" at the prompt on the Scratch window and watch your legs move

Create the Back of the Unicorn

20200726_090219.jpg
20200726_100339.jpg
20200726_101853.jpg
20200726_092303.jpg
20200726_092618.jpg
2020-08-10_0002.jpg
2020-08-10_0001.jpg

I love the shape of the Califa Farms nut milk bottles. I used one for the back and haunches of the unicorn. I had to use a box knife to make the initial cuts, but could use scissors for the final, cleaner, cuts

First, cut off the base of the bottle and the cap end which you'll use for the tail.then estimate how much to cut the sides. It's a little more than halfway along the length, but be sure to leave enough for error. You can always trim later.

Cut a flat section out of the cap end. Now, checking what you need by holding the body over the unicorn, make a reasonable estimate of the final trims. I ended up cutting more of mine at the VERY end of the building exercise!

You will need to figure our where you will attach the back to the body, cut out a hole large enough to fit a connector into, and connect to the body.

I painted the inside of the bottle with some glitter nail polish I had for kid crafts in keeping with the Rainbow Contest. Do this at the end after you've made your final fitting!

Make the Mane and Tail

20200726_103813.jpg
20200726_104541.jpg
20200726_104903.jpg
20200726_112136.jpg
2020-08-10_0006.jpg

Take a handful of pipe cleaners, and cut about 1/3 off. These will be the mane pieces. Arrange the longer pieces on a piece of painters tape, and glue to the disconnected cap end of the bottle. Take the smaller pieces and thread through the holes of a colorful 15 length studless brick. One end (the forelock end) has 3 pieces of pipe cleaner in the last hole.

Make the Head

20200804_082459.jpg

Lego instructions typically take a LOT of pictures, so I have included a PDF for the building instructions of the head.

The Common Anode RGB LED

commonAnodeRGB_LED.jpg

You are going to make your unicorn horn from the RGB LED so that the tip glows. There are 3 leads as noted in the picture. You MUST know which lead is connected to which GPIO pin so that your colors come out right. In the next step you are going to use colorful, shrinkable wire wrap to make sure you don't short your wires together, so make note of which lead goes with which wire wrap color so that you connect your unicorn horn properly.

Make the Horn

20200801_180321.jpg
20200801_152039.jpg
20200801_155505.jpg
20200801_155753.jpg
20200801_160332.jpg
20200801_204152.jpg
20200801_205758.jpg

Cut off one end of a jumper wires leaving a female socket on the other. We will use an anode RGB LED for the Unicorn horn tip. The longest leg will go to the 3.3V pin 1, so solder a (red!) wire to that one, sliding a wire wrap over the metal parts of that wire. Solder 220 ohm resisters to the other 3 legs,making sure that the resisters are staggered so that we can fit them thru the Lego holes. Slide a trimmed wire wrap over the resisters so you can keep the wires from shorting out. You are going to put the shrink wire wraps over any exposed wires. Use a heat gun on all the wire wraps to shrink them. thread everything through the middle of a colorful 3-hole beam. Create the length of the horn with a straw, cut to fit and slit up the middle so you can clip it over.

Connect Your Wires to the BrickPi GPIO Pins

2020-08-10_0008.jpg
20200810 140037

Connect the LED colors to these pins:

  • GPIO17 - pin 11 - red light
  • GPIO23 - pin 16 - green light
  • GPIO27 - pin 13 - blue light
  • pin 1 connects to the + leg of the RGB LED

The image shows the head of the unicorn. My photography equipment (my phone) and my knowlege of how to use it don't make good photos - this is the best way I can show how the horn changes colors.

Program Your Unicorn and Run!

rainbowUnicorn_scratch1.gif
rainbowUnicorn_scratch2.gif

Use the scratch code in the image. Note that these 2 images should be one, but it was too long so I cut it in half. The 3 orange "set" commands in the first image need to be directly connected to and above the "repeat 10" command.