Chapter 4: Building a LEGO Guitar

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:

Figure 4.1 – The final guitar build

Figure 4.1 – The final guitar build

In this chapter, we will break down the guitar build and coding into the following sections:

  • Building the stand (to place the guitar on when not in use)
  • Building the guitar
  • Writing the code
  • Playing the guitar
  • Making it your own

Technical requirements

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:

https://github.com/PacktPublishing/Smart-Robotics-with-LEGO-MINDSTORMS-Robot-Inventor/blob/main/Chapter%204%20Guitar%20Code.lms

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.

Building the stand

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:

Figure 4.2 – The stand for the guitar

Figure 4.2 – The stand for the guitar

Let's start building it!

Building the base

To get started, you will need the following pieces:

  • Two black 11x15 open frames
  • Two black 3x5 L beams
  • Four black connector pins

The required pieces can be seen in the following image:

Figure 4.3 – Pieces needed for the stand

Figure 4.3 – Pieces needed for the stand

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:

Figure 4.4 – The open frames connected

Figure 4.4 – The open frames connected

Next, locate the following pieces:

  • One teal T beam
  • Three black connector pins

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:

Figure 4.5 – T beam for support

Figure 4.5 – T beam for support

Let's keep building the frame up with the following pieces:

  • Two gray 8L axles with stops
  • One white axle connector
  • Two black connector pins
  • Two blue pin axle connectors
  • Two black 9L bent beams
  • Two black 11.5 double-bent beams

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:

Figure 4.6 – Clip build for guitar stand

Figure 4.6 – Clip build for guitar stand

Repeat the same steps for the other clip. You should now have these two clips assembled, as illustrated in the following image:

Figure 4.7 – Clips to help hold the guitar in the stand

Figure 4.7 – Clips to help hold the guitar in the stand

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:

Figure 4.8 – Axles connected together

Figure 4.8 – Axles connected together

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:

  • Eight black connector pins
  • Two teal 2x4 L beams
  • One white 13L beam
  • Two motors
  • Two gray perpendicular connectors

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:

Figure 4.9 – Black connector pins in top corners of open frame

Figure 4.9 – Black connector pins in top corners of open frame

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:

Figure 4.10 – 2x4 L beams connected to the white beam

Figure 4.10 – 2x4 L beams connected to the white beam

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:

Figure 4.11 – Beams attached to the open frame

Figure 4.11 – Beams attached to the open frame

Locate your motors and add two black connector pins to each motor, as illustrated in the following mage:

Figure 4.12 – Prepping the motors

Figure 4.12 – Prepping the motors

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:

Figure 4.13 – Wire organization

Figure 4.13 – Wire organization

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:

  • Four black 11L beams
  • Twelve black connector pins
  • One white panel
  • One white curved panel

The required pieces can be seen in the following image:

Figure 4.14 – Parts for the next aspect of the build

Figure 4.14 – Parts for the next aspect of the build

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:

Figure 4.15 – Building the back support for stand

Figure 4.15 – Building the back support for stand

Here is how it should look assembled to the back of the stand:

Figure 4.16 – The back support for the guitar stand

Figure 4.16 – The back support for the guitar 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:

  • Sixteen black connector pins
  • Two blue connector pins
  • One white panel
  • Two angled white panels
  • Two small-angled white panels
  • One black 11L beam
  • One teal 9L beam
  • Two teal 3x3 Technic pieces

Start by adding two black connector pins to the top of the open frame on your stand, as illustrated in the following image:

Figure 4.17 – Front view of stand with pins added to the top

Figure 4.17 – Front view of stand with pins added to the top

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:

Figure 4.18 – Angled white panel build for the stand

Figure 4.18 – Angled white panel build for the stand

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:

Figure 4.19 – 3x3 beams added to the build

Figure 4.19 – 3x3 beams added to the build

Secure these 3x3 teal Technic pieces using black connector pins and one black 11L beam across the bottom, as illustrated in the following image:

Figure 4.20 – Black beam for further support and height

Figure 4.20 – Black beam for further support and height

Locate your two small-angled white panels and four black connector pins. These can be seen in the following image:

Figure 4.21 – Using the small-angled white panels

Figure 4.21 – Using the small-angled white panels

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:

Figure 4.22 – Adhering angled white pin to the teal 3x3 pieces

Figure 4.22 – Adhering angled white pin to the teal 3x3 pieces

Let's wrap up this build portion by finding the following pieces:

  • Eight black connector pins
  • Three teal 9L beams
  • One black 11L beam
  • One black 7L beam

The required pieces can be seen in the following image:

Figure 4.23 – Additional pieces needed

Figure 4.23 – Additional pieces needed

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:

Figure 4.24 – Parts added together

Figure 4.24 – Parts added together

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:

Figure 4.25 – Securing the build with teal beams

Figure 4.25 – Securing the build with teal beams

Add two more connector pins to the white panel at the top and attach the black 7L beam, as illustrated in the following image:

Figure 4.26 – Final addition of the black beam to the build

Figure 4.26 – Final addition of the black beam to the build

You should now have two parts assembled, as follows:

Figure 4.27 – The two parts you should have built at this point in time

Figure 4.27 – The two parts you should have built at this point in time

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:

Figure 4.28 – Two parts of stand put together

Figure 4.28 – Two parts of stand put together

You have to add one last detail to the stand. Find the following pieces:

  • One blue connector pin
  • Two blue axle pins
  • Two medium-angled white panels
  • One teal 5L beam

The required pieces can be seen in the following image:

Figure 4.29 – Layout of the top piece of the stand

Figure 4.29 – Layout of the top piece of the stand

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:

Figure 4.30 – Top piece added to stand

Figure 4.30 – Top piece added to stand

Here is a front view of the stand at this point in the build:

Figure 4.31 – Front view of stand

Figure 4.31 – Front view of stand

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.

Building the guitar

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.

Assembling the neck

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:

  • One black 5x7 open frame
  • Three black connector pins
  • One teal 3x3 Technic piece
  • Two colored 3L beams of the same color (use red for this first build)
  • Four blue connector pins

The required pieces can be seen in the following image:

Figure 4.32 – Parts needed to build a color panel for the fretboard

Figure 4.32 – Parts needed to build a color panel for the fretboard

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:

Figure 4.33 – 3x3 piece attached to two 3L beams

Figure 4.33 – 3x3 piece attached to two 3L beams

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:

Figure 4.34 – One fretboard color panel complete

Figure 4.34 – One fretboard color panel complete

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:

Figure 4.35 – You will need five of these parts built using different colors

Figure 4.35 – You will need five of these parts built using different colors

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:

Figure 4.36 – The color sections of the fretboard

Figure 4.36 – The color sections of the fretboard

Once you have all five colored sections completed, you will connect them all using the following pieces:

  • Four white 13L beams
  • Four black 7L beams
  • Fourteen black connector pins
  • One gray connector pin
  • Two black 7x11 open frames

Start by adding two white 13L beams on either side of the open frames you just assembled, as illustrated in the following image:

Figure 4.37 – White beams added to hold the fretboard together

Figure 4.37 – White beams added to hold the fretboard together

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:

Figure 4.38 – Pins added to the open frames

Figure 4.38 – Pins added to the open frames

Additionally, using six black connector pins, you will then connect all four black 7L beams together, as illustrated in the following image:

Figure 4.39 – Pins added to open frames

Figure 4.39 – Pins added to open frames

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:

Figure 4.40 – Support frame built for the fretboard

Figure 4.40 – Support frame built for the fretboard

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:

Figure 4.41 – Open frames under the fretboard

Figure 4.41 – Open frames under the fretboard

When you have added the support frame, you can continue to build the guitar neck. You will need the following pieces:

  • Four teal 9L beams
  • Eight blue connector pins

Combine the four teal 9L beams together using the four blue connector pins, as illustrated in the following image:

Figure 4.42 – The teal pieces combined

Figure 4.42 – The teal pieces combined

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:

Figure 4.43 – Teal pieces added to the bottom of the fretboard

Figure 4.43 – Teal pieces added to the bottom of the fretboard

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:

  • Two black 5L beams
  • One white medium panel
  • Two angled white panels
  • Four blue connector pins
  • Two black connector pins

The required parts can be seen in the following image:

Figure 4.44 – Parts for the top of the guitar neck

Figure 4.44 – Parts for the top of the guitar neck

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:

Figure 4.45 – Completed fretboard

Figure 4.45 – Completed fretboard

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:

Figure 4.46 – Addition of the gray pins for the slide bar

Figure 4.46 – Addition of the gray pins for the slide bar

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:

Figure 4.47 – Connector pins added to each 3x3 teal piece

Figure 4.47 – Connector pins added to each 3x3 teal piece

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:

  • Two teal 9L beams
  • Two black 15L beams
  • Two black smooth flat 8L beams
  • Two black smooth flat 6L beams

The required pieces can be seen in the following image:

Figure 4.48 – Pieces needed for final section

Figure 4.48 – Pieces needed for final section

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:

Figure 4.49 – Fretboard with guardrails for the slide bar

Figure 4.49 – Fretboard with guardrails for the slide bar

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.

Building the color sensor slide bar

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:

  • One color sensor
  • Two gray H-shaped beams
  • Five black connector pins

The required pieces can be seen in the following image:

Figure 4.50 – Pieces required for the color sensor slide bar

Figure 4.50 – Pieces required for the color sensor slide bar

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:

Figure 4.51 – H pieces connected to sensor

Figure 4.51 – H pieces connected to sensor

Next up, you will need the following pieces:

  • Two teal 5L beams
  • Four black connector pins
  • Two blue pin axle connectors
  • Two black round axle connectors
  • One teal round spacer connector pin
  • One gray 3L axle

The required pieces can be seen in the following image:

Figure 4.52 – Parts to build out the slider

Figure 4.52 – Parts to build out the slider

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:

Figure 4.53 – The sliding element that slides against the flat black pieces of the fretboard

Figure 4.53 – The sliding element that slides against the flat black pieces of the fretboard

Add this piece to the right-side H gray beam:

Figure 4.54 – The slider added to the color sensor

Figure 4.54 – The slider added to the color sensor

Next, locate the following pieces:

  • One teal 5L beam
  • One teal 9L beam
  • Two blue connector pins

The required pieces can be seen in the following image:

Figure 4.55 – Parts to build out the opposite side of the piece

Figure 4.55 – Parts to build out the opposite side of the piece

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:

Figure 4.56 – Addition of the beams

Figure 4.56 – Addition of the beams

Let's finish up the slide component by locating the following pieces:

  • Four black connector pins
  • Two gray perpendicular bent pins
  • Two teal T beams
  • Four teal round spacer connector pins

Add the four black connector pins to the top of the 9L teal beam, as follows:

Figure 4.57 – Adding the black connector pins

Figure 4.57 – Adding the black connector pins

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:

Figure 4.58 – Two parts to hold onto the fretboard

Figure 4.58 – Two parts to hold onto the fretboard

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:

Figure 4.59 – Slider attachments added to the color sensor

Figure 4.59 – Slider attachments added to the color sensor

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:

  • Two white curved panels
  • Two black 5L beams
  • Six black connector pins
  • Two blue connector pins
  • Two teal round axle connectors

The required pieces can be seen in the following image:

Figure 4.60 – Parts for your hand on the slider

Figure 4.60 – Parts for your hand on the slider

Connect the two white curved panels together using the black 5L beam and four black connector pins, as illustrated in the following image:

Figure 4.61 – The parts put together

Figure 4.61 – The parts put together

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:

Figure 4.62 – Round connectors added

Figure 4.62 – Round connectors added

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:

  • Three black 5L beams
  • Two black 3L beams
  • Two blue connector pins
  • Four black connector pins

The required pieces can be seen in the following image:

Figure 4.63 – Parts to finish up the rest of this build

Figure 4.63 – Parts to finish up the rest of this build

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:

Figure 4.64 – The two parts for the slider

Figure 4.64 – The two parts for the slider

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:

Figure 4.65 – Completed build of the slider underside

Figure 4.65 – Completed build of the slider underside

This is how it looks from the top:

Figure 4.66 – Completed build of the slider topside

Figure 4.66 – Completed build of the slider topside

At this point in the build process, you should now have these two pieces assembled, as follows:

Figure 4.67 – Fretboard and slider

Figure 4.67 – Fretboard and slider

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:

Figure 4.68 – Slider added to the fretboard

Figure 4.68 – Slider added to the fretboard

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:

Figure 4.69 – Teal knobs added to give that guitar-string-nut look

Figure 4.69 – Teal knobs added to give that guitar-string-nut look

Now that your fretboard is complete, let's get the rest of the guitar body completed so that you can rock out!

Assembling the guitar body

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:

  • One Intelligent Hub
  • One teal base plate
  • Eight black connector pins
  • Two gray connector pins with bush stops
  • One white panel
  • Two teal 2x4 L beams
  • Two blue pin axle connectors

You will begin with the teal base plate that comes with the kit. This is shown in the following image:

Figure 4.70 – Teal 11x17 base plate

Figure 4.70 – Teal 11x17 base plate

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:

Figure 4.71 – White panel and teal base plate prep

Figure 4.71 – White panel and teal base plate prep

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:

Figure 4.72 – Adding the white panel to the base plate

Figure 4.72 – Adding the white panel to the base plate

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:

Figure 4.73 – Parts needed to secure the Intelligent Hub to base plate

Figure 4.73 – Parts needed to secure the Intelligent Hub to base plate

Secure the Intelligent Hub to the base plate using the 2x4 L beams and connector pins, as follows:

Figure 4.74 – The start to the body of the guitar

Figure 4.74 – The start to the body of the guitar

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:

  • Ten black connector pins
  • One white panel
  • One white skinny panel
  • One white curved panel
  • One distance sensor

Begin by adding four connector pins to the base plate in the corners of pin rows on either side, like this:

Figure 4.75 – Pin placement on the teal base plate

Figure 4.75 – Pin placement on the teal base plate

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:

Figure 4.76 – Prepping the white panel

Figure 4.76 – Prepping the white panel

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:

Figure 4.77 – Adding the flow pattern to the build

Figure 4.77 – Adding the flow pattern to the build

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:

Figure 4.78 – Body build layout

Figure 4.78 – Body build layout

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:

Figure 4.79 – Distance sensor added to the build

Figure 4.79 – Distance sensor added to the build

It's time to build the outer frame of the guitar body. You will need the following pieces to do this:

  • Three teal 9L beams
  • Two black 7L beams
  • One black 15L beam
  • Two blue connector pins
  • Sixteen black connector pins
  • Two black double-bent beams
  • Two black 3x5 L beams
  • Two teal 3x5 L beams
  • Four blue axle connector pins
  • Two red connector pins with bush stops

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:

Figure 4.80 – Connected beams

Figure 4.80 – Connected beams

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:

Figure 4.81 – Black L beams and double-bent black beams added

Figure 4.81 – Black L beams and double-bent black beams added

Here is how the frame looks when the teal 3x5 beams have been added to both sides using black connector pins:

Figure 4.82 – 3x5 teal L beams added

Figure 4.82 – 3x5 teal L beams added

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:

Figure 4.83 – Double-bent beams added

Figure 4.83 – Double-bent beams added

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:

  • Two teal round connectors
  • Six black connector pins
  • Two teal 2x4 L beams
  • Two teal 3x5 L beams

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:

Figure 4.84 – Securing the parts

Figure 4.84 – Securing the parts

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:

Figure 4.85 – 3x5 teal beams added to frame

Figure 4.85 – 3x5 teal beams added to frame

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:

  • Two gray double pin and axle connectors
  • Four white round connectors
  • Two white bumper panels
  • Two blue axle connector pins
  • One black 15L beam
  • Two red connector pins with bush stops
  • Two gray connector pins with bush stops

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:

Figure 4.86 – Parts added to balance out layers of frame

Figure 4.86 – Parts added to balance out layers of frame

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:

Figure 4.87 – Using bumper panels for the guitar frame!

Figure 4.87 – Using bumper panels for the guitar frame!

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:

Figure 4.88 – Adding the Intelligent Hub to the guitar frame

Figure 4.88 – Adding the Intelligent Hub to the guitar frame

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:

  • Eight blue pin axle connectors
  • Four black round elbow connectors
  • Four blue connector pins
  • Two teal 3L beams
  • Four white medium-angled panels

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:

Figure 4.89 – Building out the corner pieces of the guitar frame

Figure 4.89 – Building out the corner pieces of the guitar frame

Add these parts to the top corners of the guitar body, as follows:

Figure 4.90 – Body frame with the corner pieces

Figure 4.90 – Body frame with the corner pieces

You need a few more support beams to hold things together properly, so find the following pieces:

  • Four blue axle connector pins
  • One black 15L beam
  • One black 11L beam

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:

Figure 4.91 – Guitar body complete

Figure 4.91 – Guitar body complete

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:

Figure 4.92 – The final build of the guitar

Figure 4.92 – The final build of the guitar

Now that our guitar is built, let's write the code for it!

Writing the code

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.

The ports

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:

Figure 4.93 – Port view in the MINDSTORMS software

Figure 4.93 – Port view in the MINDSTORMS software

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:

Figure 4.94 – Event "when" block

Figure 4.94 – Event "when" block

Inside the grayed-out area, you will add a logic and block, which is illustrated in the following screenshot:

Figure 4.95 – Logic "and" block

Figure 4.95 – Logic "and" block

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:

.

Figure 4.96 – Sensor block for the color sensor

Figure 4.96 – Sensor block for the color sensor

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:

Figure 4.97 – Sensor block for the button press on the Intelligent Hub will default to Left

Figure 4.97 – Sensor block for the button press on the Intelligent Hub will default to Left

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:

Figure 4.98 – Extension blocks located in the white-outlined blocks at the bottom left of the screen

Figure 4.98 – Extension blocks located in the white-outlined blocks at the bottom left of the screen

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:

Figure 4.99 – The Music extension block provides many options for playing music

Figure 4.99 – The Music extension block provides many options for playing music

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:

Figure 4.100 – The basic code of the guitar for each color

Figure 4.100 – The basic code of the guitar for each color

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:

Figure 4.101 – Right-click so that you don't have to code each block over and over

Figure 4.101 – Right-click so that you don't have to code each block over and over

Now that the code is ready, let's play it!

Playing the guitar

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:

  • Tweak your code so that the sensor plays the color it sees right away. The downside is that the guitar plays every note if you need to skip a color.
  • Instead of using the right-button press to play a note, I used the distance sensor to activate the notes. I liked this at first, but I am too clumsy and kept triggering the sensor when I did not mean to. The distance sensor is shown here:
Figure 4.102 – Using the distance sensor to trigger sound

Figure 4.102 – Using the distance sensor to trigger sound

  • I used the tap feature of the Intelligent Hub when it is tapped, the note would play. Again, I found a button press to be easier, but I did use this option for some time.

Now that the guitar is built, coded, and playable, it's time to customize it to your own needs!

Making it your own

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:

  • You could use the play sound block and import your sounds. Using the Record sound option, you could pull power chords from the internet and record them to yourIntelligent Hub. Using the Edit sound option allows you to further customize the sound.
  • If you are talented, you could record yourself playing the actual chords/notes and pull that into the code.

    The Cat Meow 1 sound is shown in the following screenshot:

Figure 4.103 – Be creative and develop some unique sounds

Figure 4.103 – Be creative and develop some unique sounds

  • You could also experiment with using a block—such as the change pitch block—to change the pitch of a sound if the distance sensor is triggered or you tap the Intelligent Hub, or maybe add a motor and spin the motor.

    Here's an example of the pitch effect being changed:

Figure 4.104 – Using distance sensors to tweak sounds such as a wah-wah pedal effect

Figure 4.104 – Using distance sensors to tweak sounds such as a wah-wah pedal effect

The possibilities are endless! Have fun. Rock out. Enjoy your build!

Summary

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset