Book Image

Design Innovative Robots with LEGO SPIKE Prime

By : Aaron Maurer
5 (1)
Book Image

Design Innovative Robots with LEGO SPIKE Prime

5 (1)
By: Aaron Maurer

Overview of this book

The new LEGO SPIKE Prime is one of the latest additions to the LEGO robotics line of products. This book will help you to enjoy building robots and understand how exciting robotics can be in terms of design, coding, and the expression of ideas. The book begins by taking you through a new realm of playful learning experiences designed for inventors and creators of any age. In each chapter, you'll find out how to build a creative robot, learn to bring the robot to life through code, and finally work with exercises to test what you've learned and remix the robot to suit your own unique style. Throughout the chapters, you'll build exciting new smart robots such as a handheld game, a robotic arm with a joystick, a guitar, a flying bird, a sumobot, a dragster, and a Simon Says game. By the end of this LEGO book, you'll have gained the knowledge and skills you need to build any robot that you can imagine.
Table of Contents (9 chapters)

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