Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Design Innovative Robots with LEGO SPIKE Prime

You're reading from   Design Innovative Robots with LEGO SPIKE Prime Seven creative STEM robotic designs to challenge your mind

Arrow left icon
Product type Paperback
Published in Jan 2022
Publisher Packt
ISBN-13 9781801811576
Length 264 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Aaron Maurer Aaron Maurer
Author Profile Icon Aaron Maurer
Aaron Maurer
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

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

Coding the dragster

The code for this project is designed to achieve the following objectives:

  • The dragster needs to count down 3-2-1 to make sure people have time to move out of the way.
  • The dragster needs to stop when it sees the red (or the color of choice) finish line.
  • The dragster needs to display the time to avoid human error when using a stopwatch.

Connecting to the proper ports

Before we begin to code, you need to make sure you have all the parts properly connected to the Intelligent Hub. Start with the motors. The motors should be plugged into ports A and E. It does not matter which motor goes into which port if they are A and E, since the dragster will only move forward and backward.

Your color sensor will go into port C. This sensor will help your dragster identify and stop at the finish line:

Figure 6.47 – The port view in the software

For this program, you will have two code stacks. Additionally, you will be...

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 $19.99/month. Cancel anytime
Banner background image