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 1. Chapter 1: Getting Started with SPIKE Prime 2. Chapter 2: Building an Industrial Robot Claw 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

Writing the code

The code for the mechanical bird will use the ultrasonic sensor as both the eyes and to trigger movement. The goal is to mimic a bird in flight looking for prey, so we will work to ensure the legs move with the head gesture as well as the wing mechanics.

The ports

You will connect the ultrasonic sensor into port B. You will plug the large motor into port F. You will plug the two medium motors into ports C and D.

Figure 4.35 – Port view in the software

Calibrating the motors

This first code stack will make sure that the head and wing motors are all set to position 0 before being activated to ensure everything works smoothly and properly:

  1. Under the when program starts block, insert a purple light up block that activates the lights on ultrasonic sensor B lighting up to 0 0.
  2. Add a pink movement block named set movement speed to and make it 15%.
  3. Add a blue set speed to motor block, set it to 10%, and change it to...
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 ₹800/month. Cancel anytime}