Reader small image

You're reading from  Smart Robotics with LEGO MINDSTORMS Robot Inventor

Product typeBook
Published inMay 2021
PublisherPackt
ISBN-139781800568402
Edition1st Edition
Concepts
Right arrow
Author (1)
Aaron Maurer
Aaron Maurer
author image
Aaron Maurer

Aaron Maurer, also known as “Coffeechug” is the STEM lead for 21 school districts in Iowa helping to expand STEM, Computer Science, Makerspace, and Purposeful Play into classrooms K-12. Aaron is also a former FIRST LEGO League coach for 8 years with much success working with phenomenal kids. He has a Master Educator License with endorsements in 5-12 Psychology – 163; 5-12 World History – 166; 5-12 American History – 158; 5-12 Computer Science – 278; PK-12 Talented and Gifted – 107; 5-8 Middle School Generalist – 182; and K-8 Computer Science – 277. Currently, Aaron is a member of ISTE Making It Happen Award; Lego Education Ambassador and Master Educator; PBS Digital Innovator and All-Star; PITSCO Tag Committee; Microsoft Innovator Educator Expert; Microsoft Innovative Educator Fellow; Global Learning Mentor (formerly Skype Master Teacher); Minecraft Global Mentor; and Makey Makey Ambassador. Finally, Aaron was a finalist for the Iowa Teacher of the Year in 2014.
Read more about Aaron Maurer

Right arrow

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

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...

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

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

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...

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...

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

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...

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

  • I used the tap feature of the Intelligent Hub when it is tapped, the note would play. Again, I found a button press...

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

  • 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:

...

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.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Smart Robotics with LEGO MINDSTORMS Robot Inventor
Published in: May 2021Publisher: PacktISBN-13: 9781800568402
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Aaron Maurer

Aaron Maurer, also known as “Coffeechug” is the STEM lead for 21 school districts in Iowa helping to expand STEM, Computer Science, Makerspace, and Purposeful Play into classrooms K-12. Aaron is also a former FIRST LEGO League coach for 8 years with much success working with phenomenal kids. He has a Master Educator License with endorsements in 5-12 Psychology – 163; 5-12 World History – 166; 5-12 American History – 158; 5-12 Computer Science – 278; PK-12 Talented and Gifted – 107; 5-8 Middle School Generalist – 182; and K-8 Computer Science – 277. Currently, Aaron is a member of ISTE Making It Happen Award; Lego Education Ambassador and Master Educator; PBS Digital Innovator and All-Star; PITSCO Tag Committee; Microsoft Innovator Educator Expert; Microsoft Innovative Educator Fellow; Global Learning Mentor (formerly Skype Master Teacher); Minecraft Global Mentor; and Makey Makey Ambassador. Finally, Aaron was a finalist for the Iowa Teacher of the Year in 2014.
Read more about Aaron Maurer