Reader small image

You're reading from  Design Innovative Robots with LEGO SPIKE Prime

Product typeBook
Published inJan 2022
PublisherPackt
ISBN-139781801811576
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 3: Building a LEGO Guitar

Entertainment is an important aspect of our lives and well-being. One of the great hobbies, interests, and careers is music. As technology continues to advance in our lives, we see more technology being used to create musical, music experiences, concerts, and so on.

This chapter will be combining robotics and music by using the LEGO SPIKE Prime kit to make a guitar that is playable and codable to our unique needs.

The gaming industry 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 to your favorite song.

Here is what your guitar will look like by the end of this chapter:

Figure 3.1 – The final guitar build

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

  • Building the guitar
  • Coding the guitar
  • Playing the guitar
  • Making it your own

Technical requirements

For the building of the robot, all you will need is the LEGO SPIKE Prime kit. For programming, you will need the LEGO SPIKE Prime app/software.

Access to the code can be found here: https://github.com/PacktPublishing/Design-Innovative-Robots-with-LEGO-SPIKE-Prime/blob/main/Chapter%203%20-%20Guitar%20Code.llsp.

You can find the code in action video for this chapter here: https://bit.ly/2ZhzxXl

Let's start building it!

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 customizing the guitar will be the body of the guitar, the top of the neck of the guitar, and the 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 sound.

Let's get started with the building.

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 it to your own liking:

  1. Begin by adding four black connector pins to each of the corners of a yellow 11x19 base plate:

    Figure 3.2 – Black connector pins on the base plate

  2. Attach the second yellow 11x19...

Writing the code

The coding for the guitar is very simple in premise but allows for completely individual interpretation of 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 in the end, be brave and tinker around to get the guitar to sound like you want it. The beauty of music is that it allows you to express yourself the way you want to express yourself. 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 force sensor into port D and plug the color sensor into port C:

Figure 3.32 – The 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 deleting the default yellow event block called when program starts. Right-click...

Playing the guitar

The beauty of Bluetooth is that you can continuously tinker with your code while you play your guitar and 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:

  • Coding to simply see the color and to play without the force sensor
  • Using the tap feature of the Intelligent Hub – when the brick is tapped, the note would play

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 purple sound play sound block and import your sounds. Using the record… option, you could play power chords from the internet and record them to your Intelligent Hub. Using edit sounds… 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:

Figure 3.43 – Be creative and develop some unique sounds

You could also experiment using a block, such as the changing pitch block to change the pitch of a sound if the distance sensor is triggered (think of a whammy bar on an electric guitar) or if you tap the brick, or maybe add a motor to spin.

The possibilities are endless!

Figure 3.44 – Use distance sensors to tweak sounds like...

Summary

In summary, we explored how to make an instrument with a robotics kit. 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 coding by understanding the different ways we can take a simple code program and make it work to our liking.

In the next chapter, you will explore another aspect of life to see how you can adapt ideas learned from nature to build a robot with a killer instinct – by making a bird.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Design Innovative Robots with LEGO SPIKE Prime
Published in: Jan 2022Publisher: PacktISBN-13: 9781801811576
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