Entertainment is an important aspect of our lives and well-being. Music is a great hobby and interest for people and it also creates career-making opportunities. As technology continues to advance in our lives, we see it increasingly being used to create music, music experiences, concerts, and more.
This chapter will be combining robotics and music by using the Robot Inventor kit to make a guitar that is playable and codable to our unique needs.
With a gaming industry that was impacted by the awesomeness of Guitar Hero and the likes of many other music games, let's create our own instrument that will allow you to jam out to your favorite song.
Here is what your guitar will look like by the end of this chapter:
In this chapter, we will break down the guitar build and coding into the following sections:
For the building of the robot, all you will need is the Robot Inventor kit. For programming, you will need the LEGO MINDSTORMS app/software.
Access to the code for this chapter can be found here:
If you would like a more detailed photo-by-photo build process of the robot, please head here to view the images: https://bit.ly/3czErS3.
Before we build the actual guitar, we will start with building a stand to place the guitar when it is not in use. The stand is not a super-detailed creation as it uses the elements left over from the guitar build, but it serves a purpose and achieves the necessary function.
The base will look like this when complete:
Let's start building it!
To get started, you will need the following pieces:
The required pieces can be seen in the following image:
You will start by grabbing two of the open frames and securing them together using the 3x5 L beams. This part is the main frame of the stand. You will stand them in a perpendicular fashion. Use two black connector pins with each of the L beams, using one pin on the 3L side of the beam and another on the 5L side of the beam, as illustrated in the following image:
Next, locate the following pieces:
The teal T Technic piece is going to help secure the open frame together. Place the black connector pins on the ends of the T piece and in the middle pin hole of the middle beam of the T piece. Secure this piece to connect the two open frames together, as illustrated in the following image:
Let's keep building the frame up with the following pieces:
Next, you will build two arms that will allow you clip the guitar stand to better hold it in place and keep it from slipping down the stand. The clip sits on the main body of the guitar, as you can see in Figure 4.1.
You will connect the double-bent beams and single-bent beams together using one black connector pin and one blue pin axle connector. Note the build on the right side of the following image to see how it should look:
Repeat the same steps for the other clip. You should now have these two clips assembled, as illustrated in the following image:
Use the 8L gray axles and the white axle connector to attach these clips to the base that we just built using the open frames. Insert a gray 8L axle through the pin hole on each side of the open frame. Before you connect them with the white-axle-connector piece, be sure you slide a clip onto each gray axle. Once you have done that, then connect the two axles using the white-axle-connector piece. You should then have this piece connected through the open frame, as seen in the following image:
The guitar has some weight to it, and therefore we need a counterweight for the stand so that it does not tip over. The kit does not come with weights by nature, but we can rethink the use of the motors to serve as weights. Even better is that the motors can clip quite easily to the side of the stand. We will use two motors, but if you need to add more, it is quite easy to add motors to the front of the stand as extra weight.
You will need the following pieces:
To begin with the counterweight build, add two black connector pins to the upper corners of the back of the stand, as illustrated in the following image:
Add a teal 2x4 L beam to the ends of the white 13L beam using a black connector pin for each L beam, as illustrated in the following image:
Using the black connector pins you recently added to the back of the frame, attach this piece to the stand, as illustrated in the following mage:
Locate your motors and add two black connector pins to each motor, as illustrated in the following mage:
Secure the motors to the side of the stand using these connector pins. Once you do that, add the two gray perpendicular connectors to secure the wires so that they are out of the way, as illustrated in the following image:
Now that you have added some counterweight, you need to add some additional support to the back of the stand to provide additional structural support in order to keep the stand from toppling over when you place the guitar onto the stand.
You will need the following pieces:
The required pieces can be seen in the following image:
The next part of this stand's construction is to make sure that it does not fall backward. The motors are important, but they can't prevent the guitar from falling over completely. You will need to add some support to the back of the stand to help keep the guitar propped up.
Start with one of the black 11L beams. Secure the white panel to this beam. Next, add the white curved panel. Lastly, add the three black 11L beams. Using two more black connector pins you will be able to attach this to the back of the stand, as illustrated in the following image:
Here is how it should look assembled to the back of the stand:
You can now build the next part of the stand, and that is the part that gives the guitar something to lean on while it is in place. Using some of the basic elements and avoiding the pieces we need for the guitar build, we can create a nice piece that looks somewhat like a guitar neck to match the stand with the guitar itself.
You will need the following pieces:
Start by adding two black connector pins to the top of the open frame on your stand, as illustrated in the following image:
Next, assemble the white panel and angled white panel pieces together using black connector pins. Use two connector pins for each panel and two for the bottom of the white panel. Add a teal 9L beam across the bottom to hold all the pieces together, as illustrated in the following image:
Add a black and blue connector pin to each of the angled white panels and then attach a 3x3 teal Technic piece to each of these pins. The black connector pin goes to the outside bottom pin hole and the blue connector pin goes to the inside pin hole on the bottom, as illustrated in the following image:
Secure these 3x3 teal Technic pieces using black connector pins and one black 11L beam across the bottom, as illustrated in the following image:
Locate your two small-angled white panels and four black connector pins. These can be seen in the following image:
Connect these small-angled white panels to the 3x3 teal Technic pieces, as shown in the following image. Add a black connector pin to the bottom of each of these small-angled white panel pieces:
Let's wrap up this build portion by finding the following pieces:
The required pieces can be seen in the following image:
The previous image provides a layout of how all these parts fit together. Basically, we are trying to add some height to this portion of the stand to properly support the neck of the guitar. Add these pieces together by starting one of the teal 9L beams. Using two black connector pins, attach a second teal 9L beam to this beam. Repeat the process by adding another two black connector pins to the teal 9L beam to be able to attach the 11L black beam, as illustrated in the following image:
Add these beams to the black connector pins on the small-angled white panels. After you do that, then go ahead and hold it all together by adding another teal 9L beam across the back using the two blue connector pins that are already on the build, as illustrated in the following image:
Add two more connector pins to the white panel at the top and attach the black 7L beam, as illustrated in the following image:
You should now have two parts assembled, as follows:
Go ahead and attach the part with all the white panels to the stand using the black connector pins that are sitting on top of the open frame, as illustrated in the following image:
You have to add one last detail to the stand. Find the following pieces:
The required pieces can be seen in the following image:
Assemble the parts as shown in the preceding image, using the blue connector pin to join the teal 5L beam in the middle of the angled white panels. Once you have the blue connector pin holding the two white curved panels together with the teal 5L beam in between them, then go ahead and add the two blue axle pins to the bottom of each white curved panel so that you can add this piece to the top of the stand. This piece will attach to the top of the guitar stand.
Here is the completed build of the stand:
Here is a front view of the stand at this point in the build:
Go ahead and set this stand aside as we build the guitar that will eventually use this stand. But so that you can get a sense of how this works, check out how the guitar sits in the stand by referring to the first image in this chapter labeled Figure 4.1.
You will build the guitar in sections. Each section will provide a basic framework for the guitar, but please keep in mind that with all the builds you have the space and opportunities to build it the way you want. In terms of the guitar, the key pieces to customize it will be the body of the guitar, the top of the neck of the guitar, and the light-emitting diode (LED) lights. Additionally, when you get to the coding, you can really fine-tune it to have the guitar sound just the way you want it to.
Let's get started with the building.
We will start with the neck of the guitar. For this, we are going to use the 1x3 colored Technic pieces to create sections for the color sensor to detect. The color sections are reminiscent of the Guitar Hero guitars, but instead of pressing buttons we will use the color sensor to detect the colors.
You will build five different colored sections for the fretboard. This maximizes the length of the color sensor wire and gives the player five different notes to play. Let's build one together.
You will need the following pieces to build one of these guitar panels. You will build five of these in total, so repeat this part element five times to complete the guitar neck:
The required pieces can be seen in the following image:
Start this part of the build by adding two black connector pins to the side of the 3x3 teal Technic piece. Connect a 3L beam to the connector pins. Next, add a black connector pin in the middle pin hole of the 3L beam. Attach the second 3L beam.
The result can be seen in the following image:
That piece will fit inside the 5x7 open frame. Secure it in place using the four blue connector pins by using the 2L side of the pin to connect the frame to this piece, as illustrated in the following image:
You will repeat this same process, assembling five of these open frames. In the book example, you will use the colors red, green, white, blue, and yellow. Go ahead and repeat this process until you have five completed panels.
The following image shows five parts being assembled:
Once you have the five parts assembled, then it is time to connect them all together to begin building the fretboard of the guitar. Line them all up with the blue connector pins sticking out on the sides, as illustrated in the following image:
Once you have all five colored sections completed, you will connect them all using the following pieces:
Start by adding two white 13L beams on either side of the open frames you just assembled, as illustrated in the following image:
Next, find your two 7x11 open frames and add two black connector pins to the 7L side of each of the open frames, as illustrated in the following image:
Additionally, using six black connector pins, you will then connect all four black 7L beams together, as illustrated in the following image:
Connect the two open frames together by adding the four black 7L beams to the middle of them. Add the gray connector pin to the middle pin hole of one of the open frames, and the opposite open frame should have two black connector pins on the outside pin holes on top, as illustrated in the following image:
Now, you can add the open frame build to the fretboard. Make sure when you connect the support frames to the back side that you make the open frame flush with the sections that have the color block, leaving the one extra space open. Note this in the following image, where the gray connector pin is open and shown:
When you have added the support frame, you can continue to build the guitar neck. You will need the following pieces:
Combine the four teal 9L beams together using the four blue connector pins, as illustrated in the following image:
This piece will connect to the top side of the fretboard covering the open frame below that has the gray connector pin showing, as illustrated in the following image:
The final step for the fretboard is to add the top part, where the strings can be tightened on a regular guitar. We don't have strings, but we can still add the top part to make sure it looks incredible. You should have the following pieces remaining to build this part of the guitar:
The required parts can be seen in the following image:
Connect the black 5L beams to smooth out the fretboard and the top of the guitar. There is also another one on the back, securing the white pieces. Use the blue connector pins to join the black 5L beams to the fretboard and the top of the guitar. Use the black connector pins to join the white panels, as illustrated in the following image:
The final touch before you move on to the next build structure is to add eight gray connectors of ½ size. These will be added to the fretboard on the teal 3x3 Technic pieces. Please note how the layout of these pieces alters on each teal 3x3 piece.
Important note
Note the placement of the small gray connector pins. These are tough to get out, so be careful!
The result can be seen in the following screenshot:
Once you do that, then add ten black connector pins to the fretboard. Two pins go to each 3x3 teal Technic piece, as illustrated in the following image:
Now that you have the basic layout of your guitar fretboard complete, you need to add the guard rails that will be part of the color sensor slide component to play your guitar.
You will need the following pieces:
The required pieces can be seen in the following image:
To build the guardrails, use the 9L teal beams and the black 15L beams, and add them to the black connector pins. One teal and one black beam go on each side. Next, add the flat pieces between the rails. Note that these pieces will lay over the teal beams using the gray ½ connector pins connected to the fretboard.
The result can be seen in the following image:
Ensure everything is solid and connected. If you need to go back and support any elements further, you should do so now.
Let's move on to the color sensor build component so that we can actually play the guitar.
The next piece we need to build is the slide bar, which will allow the color sensor to slide up and down the fretboard to read the colors of the 1x3 Technic pieces we just put on the fretboard.
The device you are building will allow you to take it off when not in use and also provides a nice place for your thumb while playing.
To get started, you will need the following pieces:
The required pieces can be seen in the following image:
The H pieces are incredible for building out the structure of the frame. Add four black connector pins to the sides of the color sensors. Use these pins to attach the H beams to either side of the color sensor. Add one black connector pin to the right side of this piece, as illustrated in the following image:
Next up, you will need the following pieces:
The required pieces can be seen in the following image:
On one side, you will add the component that will slide up and down the smooth black flat pieces on the fretboard. Use two black round axle connectors by connecting them together, using a 3L axle piece with one teal round spacer connector pin between them. Next, add the teal 5L beams across, using the blue axle connector pins and black connector pins. This will give the proper distance for the sensor to read the colors of the fretboard.
The result can be seen in the following image:
Add this piece to the right-side H gray beam:
Next, locate the following pieces:
The required pieces can be seen in the following image:
On the H beam on the left that currently does not have any pieces built upon it yet, you will start by adding one 5L teal beam, followed up with one 9L beam, using the blue connector pins. This is illustrated in the following image:
Let's finish up the slide component by locating the following pieces:
Add the four black connector pins to the top of the 9L teal beam, as follows:
Next, you will be building two of the same parts designed to hold the color sensor slider onto the fretboard. To do this, you will start with the gray perpendicular connector pins and add two teal round spacer connector pins to two of the pins and the T beam on the other two connector pins, as illustrated in the following image:
These two parts will need to be attached to the slide component to finish up this current build part, as illustrated in the following image:
The slider will use the teal round connectors as rollers along the fretboard. Before we add this piece to the guitar, you still have more to build on the slide bar before completing this section of the guitar, but let's set this part aside while we build the next part of this slider, which will give your hands a place to rest.
You will start with the following pieces:
The required pieces can be seen in the following image:
Connect the two white curved panels together using the black 5L beam and four black connector pins, as illustrated in the following image:
Next, add two black connector pins to the underside of one of the white curved panels. On the other panel, add two blue connector pins. On the blue connector pins, add a black 5L beam and then two teal round connectors, as illustrated in the following image:
Again, you are using the teal round connectors to slide along the fretboard, like you did in a previous step. Next, find the following pieces:
The required pieces can be seen in the following image:
The previous image not only gave you a visual of the pieces, but also how they go together. You will build these pieces to the white panel that has the black connector pins. Stack the 5L beams followed by the two 3L beams. Add a black 5L beam to the black connector pins on the white panel piece. Use two more black connector pins to add another black 5L beam. Do the same thing again, using two black connector pins to add the third black 5L beam. Lastly, use the blue connector pins to secure the two black 3L beams to these three black 5L beams.
The result can be seen in the following image:
This new piece will connect the color sensor build you built previously. It slides and connects to the side where the black round connector part is on the color sensor. It will connect to the gray H beam.
This is how the completed build looks on the underside:
This is how it looks from the top:
At this point in the build process, you should now have these two pieces assembled, as follows:
The color sensor build will wrap around the fretboard. The white curved panels wrap around the edge of the fretboard. The black round connectors with the teal round connector in the middle will slide on the flat beams on the fretboard. Finally, the left side will connect along the white beam edge by ensuring the white beam sits between the teal round connectors on the gray perpendicular pins.
The result can be seen in the following image:
The last little final touch to this section is to use two blue axle pins to connect to the two teal round axle connectors. Add these to the top of the fretboard, as follows:
Now that your fretboard is complete, let's get the rest of the guitar body completed so that you can rock out!
This is where you get to spice up the guitar to your liking. For the sake of this example you will build a basic outline of a guitar, but please know that from here, you can design a guitar to your own liking.
Let's get started!
You will need the following pieces:
You will begin with the teal base plate that comes with the kit. This is shown in the following image:
Add two black connector pins to one side of the base plate and four black connector pins to the white panel, along with two gray connector pins to the top side of the white panel, as illustrated in the following images:
Attach this white panel to the base plate. Add it to the same side you added the two black connector pins on the side. Be sure you leave two rows of space open from the edge, as shown in the following image. Connect the white panel to the base plate using the gray pins:
Next, slide the Intelligent Hub next to the white panel and connect it using the two black connector pins. Then, find the 2x4 L beams, two black connector pins, and the two blue pin axle connectors. These can be seen in the following image:
Secure the Intelligent Hub to the base plate using the 2x4 L beams and connector pins, as follows:
You need to extend the size of the guitar body beyond the teal base plate. You will use some of the white panels to do this.
You will need the following pieces for this portion of the build:
Begin by adding four connector pins to the base plate in the corners of pin rows on either side, like this:
Next, add four black connector pins to one of the white panels. Two will go on the top and two on the side, as illustrated in the following image:
Slide this white panel onto the edge of the base plate and then secure these two parts together with the white skinny panel, like this:
Use the two black connector pins that have not been used yet to add the white curved panel. The connector pins are used to join the Intelligent Hub to the white curved panel. The result can be seen in the following image:
Go ahead and attach the distance sensor to the side of the base plate and Intelligent Hub. This is an optional part of the guitar, depending on how you play your guitar. This is a good time to add it before you build out around the rest of the body. The distance sensor can be used for a variety of purposes, which we will explore in the coding section. Later, if you decide you don't need it then it is easy to remove it, but for now let's add it so that you have it to experiment with.
The result can be seen in the following image:
It's time to build the outer frame of the guitar body. You will need the following pieces to do this:
Start with the 15L beam. Attach one of the teal 9L beams using the blue connector pins on both ends of the beam so that it is centered in the middle of the 15L beam. Add the two remaining teal 9L beams on either side, using the black connector pins to connect them to the black 7L beams lined up on either side of the 15L beam.
The result can be seen in the following image:
Next, you will use the black double-bent beams and the black 3x5 L beams added to this previous structure to build out the frame. You will need to use two black connector pins to connect the build you just assembled, as well as two black pins to connect the black 3x5 L beams to the double-bent beam to hold it in place.
At this point, you will have the teal 3x5 L beams and four black connector pins left, as can be seen in the following image:
Here is how the frame looks when the teal 3x5 beams have been added to both sides using black connector pins:
Continue to build out the body. Use the black double-bent beams and two blue axle connector pins. Also, add a red connector pin with bush stop with another blue axle pin connected to the top of the red pin to secure the piece in place, as illustrated in the following image:
This is the part where you can begin to have fun with your guitar body if you want to design your own style. For now, let's start a new part list to finish up the rest of the guitar body build, as follows:
Add a black connector pin to the corner slot of each of the 2x4 L beams. Connect each of these to the corners using the blue connector pins that are available. The result should look like this:
Using two black connector pins for each of the two teal 3x5 L beams, add them to the black double-bent beams on the frame, as follows:
You are getting close! Can you hear your favorite song start to play in your mind? Go ahead and find the following pieces to continue building out the guitar body:
Add two white round connectors to one side of each of the gray double pin and axle connectors. Use this connector to connect the latest 3x5 teal beam to the rest of the frame. The result should look like this:
Use the two blue axle connector pins to connect the white bumper panels to each side of the frame. Secure the two bumper frames using the 15L black beam, and secure these pieces together using the two red connector pins. Finally, add two gray connector pins to each inner part of the white bumpers.
The result should look like this:
Now, connect the guitar body frame to the Intelligent Hub build using the pins that are available and secure all the parts.
The result should look like this:
Let's now add a little flair to the guitar body. We need to bring it to life just a bit more, so go ahead and find the following pieces:
You will build two pieces that will give some detail to the guitar body. The next image has one complete version and another one with the parts laid out to show how to assemble these. To build this out, start by connecting two blue connector pins through the pin holes of the teal 3L beam. Use these pins to secure the teal 3L beam between the two angled white panels. Next, add the blue axle pins to both axle holes of the black round elbow connectors. Attach two of these black round elbow connectors to the bottom of both angled white panel pieces. Have a look at the following image for an overview of this:
Add these parts to the top corners of the guitar body, as follows:
You need a few more support beams to hold things together properly, so find the following pieces:
Add the blue axle connector pins to the tops of the gray and red bush connectors, and then attach the beams across the bumper panels.
The result should look like this:
Finally, it is the moment you have been waiting for—the final guitar step. Go ahead and add the fretboard to the body, and begin your rock-and-roll dreams! The fretboard slides into the body and connects with the pins to hold everything in place.
Plug the color sensor into port C and the distance sensor into port D. Go ahead and strengthen any parts you wish to strengthen, or take time to design the body the way you want your guitar to look. This is a great time to customize the guitar to your liking.
The final build of the guitar can be seen here:
Now that our guitar is built, let's write the code for it!
The coding for the guitar is based on a very simple premise but allows for a complete individual interpretation on how you want to play the guitar and how you want the guitar to sound.
The program we are writing as an example will showcase some possibilities, but utimately, you should be brave and tinker around to get the guitar to sound how you want. The beauty of music is to express yourself the way you want to. This is your moment! Combining coding and music is an exciting combination of awesome.
There is not a lot to plug in for this build. You will connect the distance sensor into port D. You will also add the color sensor plugged into port C.
The following screenshot illustrates this:
The basic layout of the program will follow this structure for each of the colored items on your guitar fretboard.
You will start by adding the yellow event block called when, shown in the following screenshot:
Inside the grayed-out area, you will add a logic and block, which is illustrated in the following screenshot:
Inside each of the empty spaces of this logic block you will add two conditions, using the Sensor blocks. First, you will add the color sensor block and will set the color to the first color on your fretboard. This is illustrated in the following screenshot:
.
The second sensor condition will be the buttons on the Intelligent Hub itself. For my part, I found out I really preferred the right-button press, but you can adjust this to meet your needs. When you drag the button-press block over, it is in Left button mode by default, as illustrated in the following screenshot. You will need to click the arrow next to the word Left and select Right to change it:
Next, you need to add some extension blocks to be able to code music. Click on the extension block icon at the bottom left of the programming menu. From there, install the Music blocks, which can be seen in the following screenshot:
The Music extension block provides you with a nice selection of ways to play music. You can experiment around to have the guitar play the notes and music that you prefer. You can have a lot of fun tinkering around, tuning your guitar to how you want it to play and sound. Some of the music options can be seen here:
In the next screenshot, you can see how the program comes together to play the notes for each color reading. I really liked the sound of the choir, for some reason. I found some basic sheet music for a song I knew I could handle (I am not musical at all) and changed all the notes to reflect what was needed to play the riff of Smoke on the Water by Deep Purple.
Additionally, I coded the LED lights on the Intelligent Hub to display the note or chord being played with each color, as illustrated here:
Once you have one color coded, you simply right-click on the selection of blocks and duplicate it four more times. For each one, you change the color of the color sensor and the note being played. This is illustrated in the following screenshot:
Now that the code is ready, let's play it!
The beauty of Bluetooth is that you can continuously tinker with your code while you play your guitar and you do not need to be tethered to the computer. The music comes from the computer, so make sure your audio is turned up.
While playing the guitar, you can adjust how the music plays. I tried several options to find what I liked and share them with you here:
Now that the guitar is built, coded, and playable, it's time to customize it to your own needs!
I can't wait to see how you design your guitar and how you play it. Here are a few other ideas that you could use to make your own custom guitar:
The Cat Meow 1 sound is shown in the following screenshot:
Here's an example of the pitch effect being changed:
The possibilities are endless! Have fun. Rock out. Enjoy your build!
In summary, we explored how to make an instrument with a robotics kit, and we remixed the idea of a robotics kit to make a musical instrument. There is great power in taking something we all know and love and trying to make a robotic version of it. We explored some new build techniques by using some of the basic elements that are found in the kit to create new ideas, such as the guitar slider.
Finally, we explored the coding by taking what is a simple coding program but understanding the many different ways we can take some simple code and make it work to our personal liking.
In the next chapter, you will explore another aspect of life to see how you can adapt ideas taken from nature to build a robot with a killer instinct, by making a scorpion.
54.210.83.20