Introduction: BrickPi - Rainbow Unicorn
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!)
An extra Lego Mindstorms Ultrasonic sensor
- 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
- BrickPi3 Base kit PLUS
- Raspberry Pi 3 or better and all its cables
- 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
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
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!
Step 1: Set Up the BrickPi With the Raspberry Pi
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.
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.
Step 2: 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.
Step 3: Add Your 2x7 14-pin Right Angle Female Header (optional) and the BrickPi
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)
Step 4: Set the BrickPi Into a Lego Case
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!
Step 5: Make Your Lego Creation
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.
Step 6: Torso and Motor
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 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.
Step 7: Legs
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.
Step 8: Add BrickPi, It's Support Bricks, Test Bracing and Motor Test
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
Step 9: Create the Back of the Unicorn
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!
Step 10: Make the Mane and Tail
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.
Step 11: Make the Head
Lego instructions typically take a LOT of pictures, so I have included a PDF for the building instructions of the head.
Step 12: The Common Anode RGB LED
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.
Step 13: Make the Horn
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.
Step 14: Connect Your Wires to the BrickPi GPIO Pins
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.
Step 15: Program Your Unicorn and Run!
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.
Participated in the
Colors of the Rainbow Contest