Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Design Innovative Robots with LEGO SPIKE Prime

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

Product type Book
Published in Jan 2022
Publisher Packt
ISBN-13 9781801811576
Pages 264 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Aaron Maurer Aaron Maurer
Profile icon Aaron Maurer

Table of Contents (9) Chapters

Preface Chapter 1: Getting Started with SPIKE Prime Chapter 2: Building an Industrial Robot Claw Chapter 3: Building a LEGO Guitar Chapter 4: Building a Mechanical Bird Chapter 5: Building a Sumobot Chapter 6: Building a Dragster Chapter 7: Building a Simon Says Game Other Books You May Enjoy

Writing the code

The code you are going to create is one where the robot will be able to do the following:

  • Stay in the arena by stopping and backing up when the white rim of the arena is detected.
  • Speed up to push an opponent out of the arena when the ultrasonic sensor detects an object up close.
  • Speed up to push an opponent out of the arena when the force sensor detects touch from behind.

In all, there are six code stacks to make this happen. Let's begin.

The ports

You will connect the medium motors to ports C and F, the color sensor to port A, the ultrasonic sensor to port D, and the force sensor to port E:

Figure 5.40 – The port view in the software

Before you code, you will need to add a More Movement extension block to your coding options. At the bottom left of your coding canvas, there is an extension block icon. Click on this icon, click on Show block extensions and select More Movement:

...
lock icon The rest of the chapter is locked
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.
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}