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)

Coding a rock, paper, scissors wrist game

You are now going to code this wrist game to be able to randomly choose rock, paper, or scissors. You can play it against yourself or use it against another human. If you have a friend that has a kit, then you can both build one and compete this way. Start by opening up New Project and giving your project a name such as Rock Paper Scissors:

  1. Using the default yellow when program starts block, add a purple light block named write Hello. You will need to change the word from Hello to Left.

    Figure 1.34 – "Left" being programmed on the screen

  2. Add two yellow Events blocks named when Left Button pressed and when Right Button pressed.
  3. Go to the pink My Block sections of the coding blocks and make two new blocks. Name one start game and the other play again. Add these new blocks to the yellow blocks. Add the start game block for the left button and play again for the right button.

    Figure 1.35 – Decision making with...