Lego Mindstorms NXT-G Programming Guide, Second Edition

Book description

James Kelly'sLEGO MINDSTORMS NXT-G Programming Guide, Second Edition is a fountain of wisdom and ideas for those looking to master the art of programming LEGO's MINDSTORMS NXT robotics kits. This second edition is fully-updated to cover all the latest features and parts in the NXT 2.0 series. It also includes exercises at the end of each chapter and other content suggestions from educators and other readers of the first edition.

LEGO MINDSTORMS NXT-G Programming Guide, 2nd Edition focuses on the NXT-G programming language. Readers 10-and-up learn to apply NXT-G to real-life problems such as moving and turning, locating objects based upon their color, making decisions, and much more. Perfect for for those who are new to programming, the book covers the language, the underlying mathematics, and explains how to calibrate and adjust robots for best execution of their programming.

  • Provides programming techniques and easy-to-follow examples for each and every programming block

  • Includes homework-style exercises for use by educators

  • Gives clear instructions on how to build a test robot for use in running the example programs

Table of contents

  1. Copyright
  2. About the Author
  3. About the Technical Reviewer
  4. Acknowledgments
  5. Introduction
  6. 1. Robots and Programs
    1. 1.1. What Is a Robot?
    2. 1.2. What Is a Program?
    3. 1.3. Programs are for Humans Too
    4. 1.4. Programs are Merely Instructions
    5. 1.5. The Challenge of Programming
    6. 1.6. NXT-G
  7. 2. Program Structure
    1. 2.1. What Do I Mean by Structure?
    2. 2.2. Planning Your Program's Structure
    3. 2.3. Moving Into Real Code
    4. 2.4. Exercises
      1. 2.4.1. Exercise 2-1. Move One Object Nearer to Another
      2. 2.4.2. Exercise 2-2. Place Objects at Corners
    5. 2.5. What's Next?
    6. 2.6. Exercise Solutions
      1. 2.6.1. Exercise 2-1
      2. 2.6.2. Exercise 2-2
  8. 3. Hello World!
    1. 3.1. Programming the DISPLAY Block
    2. 3.2. Waiting for the Results
    3. 3.3. Doing More with DISPLAY
    4. 3.4. Understanding Data Hubs
    5. 3.5. Exercises
      1. 3.5.1. Exercise 3-1. Display Your Own Text
      2. 3.5.2. Exercise 3-2: Draw a Rectangle
    6. 3.6. What's Next
    7. 3.7. Exercise Solutions
      1. 3.7.1. Exercise 3-1
      2. 3.7.2. Exercise 3-2
  9. 4. Get Movin'
    1. 4.1. The MOVE block
    2. 4.2. Moving Forward and Backward
    3. 4.3. Stopping
    4. 4.4. Steering
    5. 4.5. Power Settings
    6. 4.6. Duration Settings
    7. 4.7. Braking and Coasting
    8. 4.8. Exercises
      1. 4.8.1. Exercise 4-1. Drive in a Circle
      2. 4.8.2. Exercise 4-2: Make an "S"
    9. 4.9. What's Next?
    10. 4.10. Exercise Solutions
      1. 4.10.1. Exercise 4-1
      2. 4.10.2. Exercise 4-2
  10. 5. Record and Playback
    1. 5.1. The RECORD/PLAY Block
    2. 5.2. Recording Movement
    3. 5.3. Replaying Movement
    4. 5.4. Having Fun with Record/Play
    5. 5.5. Exercises
      1. 5.5.1. Exercise 5-1: Record a Cha-cha-cha Movement
      2. 5.5.2. Exercise 5-2: Roll Forwards and Backwards First
    6. 5.6. What's Next?
    7. 5.7. Possible Solutions to Exercises
      1. 5.7.1. Exercise 7
      2. 5.7.2. Exercise 8
  11. 6. Make Some Noise!
    1. 6.1. The SOUND Block
      1. 6.1.1. Action Settings
        1. 6.1.1.1. Sound File
        2. 6.1.1.2. Tone
      2. 6.1.2. Note Settings
      3. 6.1.3. Control Settings
      4. 6.1.4. Function Settings
      5. 6.1.5. Volume Settings
      6. 6.1.6. Wait Settings
    2. 6.2. Custom Sounds
    3. 6.3. Exercises
      1. 6.3.1. Exercise 6-1
      2. 6.3.2. Exercise 6-2
    4. 6.4. What's Next?
    5. 6.5. Possible Solutions to Exercises
      1. 6.5.1. Exercise 6-1
      2. 6.5.2. Exercise 6-2
  12. 7. Wired!
    1. 7.1. The Problem
    2. 7.2. A Simple Solution
    3. 7.3. The NXT-G Solution
    4. 7.4. An Example
    5. 7.5. Types of Data
    6. 7.6. Variables
    7. 7.7. A Real NXT-G Block
    8. 7.8. What's Next?
  13. 8. True or False?
    1. 8.1. One or the Other
    2. 8.2. Sensors: Yes or No
    3. 8.3. Variables and the Logic Type
    4. 8.4. Using Logic to Configure Settings
    5. 8.5. Exercise 11
    6. 8.6. What's Next?
    7. 8.7. Exercise Solution
  14. 9. Feedback
    1. 9.1. What's Your Condition?
    2. 9.2. Configuring the Sensors
      1. 9.2.1. NXT Touch Sensor
      2. 9.2.2. RIS Touch Sensor
      3. 9.2.3. NXT Sound Sensor
      4. 9.2.4. NXT Light Sensor
      5. 9.2.5. RIS Light Sensor
      6. 9.2.6. NXT Ultrasonic Sensor
      7. 9.2.7. NXT Rotation Sensor
      8. 9.2.8. RIS Rotation Sensor
      9. 9.2.9. NXT Color Sensor
      10. 9.2.10. RIS Temperature Sensor
    3. 9.3. Other Input Types
    4. 9.4. Data Hub Power
    5. 9.5. Exercise 9-1
    6. 9.6. What's Next?
    7. 9.7. Exercise Solution
  15. 10. Wait for It!
    1. 10.1. The WAIT Block
      1. 10.1.1. The LIGHT SENSOR WAIT Block
      2. 10.1.2. The NXT BUTTONS WAIT Block
      3. 10.1.3. The ROTATION SENSOR WAIT Block
      4. 10.1.4. The SOUND SENSOR WAIT Block
      5. 10.1.5. The TIMER WAIT Block
      6. 10.1.6. The TOUCH SENSOR WAIT Block
      7. 10.1.7. The ULTRASONIC SENSOR WAIT Block
      8. 10.1.8. The COLOR SENSOR WAIT Block
      9. 10.1.9. Exercise 10-1
    2. 10.2. What's Next
    3. 10.3. Exercise Solution
  16. 11. Round and Round
    1. 11.1. Do It Again and Again and Again ...
    2. 11.2. Nested Loops
    3. 11.3. Exercise 11-1
    4. 11.4. What's Next?
    5. 11.5. Exercise Solution
  17. 12. Decisions, Decisions
    1. 12.1. Left or Right? Door One or Door Two?
    2. 12.2. Flat and Tabbed Views
    3. 12.3. Choices
    4. 12.4. More Than Two Conditions
    5. 12.5. Default Decisions
    6. 12.6. Execution!
    7. 12.7. Exercise 12-1 Left or Right?
    8. 12.8. What's Next?
    9. 12.9. Exercise Solution
  18. 13. Stop It!
    1. 13.1. The STOP Block
    2. 13.2. A Looping Example
    3. 13.3. An Unconditional STOP
    4. 13.4. A SWITCH to a STOP
    5. 13.5. STOP for Testing
    6. 13.6. What's Next?
  19. 14. Pick a Card, Any Card
    1. 14.1. The RANDOM Block
    2. 14.2. The NUMBER TO TEXT Block
    3. 14.3. Exercise 14-1
    4. 14.4. What's Next?
    5. 14.5. Exercise Solution
  20. 15. Apples and Oranges
    1. 15.1. Logic
    2. 15.2. A Random Example
    3. 15.3. The COMPARE Block
    4. 15.4. The Display of Logic Values
    5. 15.5. A Test Run
    6. 15.6. Exercise 15-1 Happy or Sad
    7. 15.7. What's Next?
    8. 15.8. Exercise Solution
  21. 16. Inside or Out?
    1. 16.1. The RANGE Block
    2. 16.2. Exercise 16-1 Outside a Range
    3. 16.3. What's Next?
    4. 16.4. Exercise Solution
  22. 17. Yes? No? Maybe?
    1. 17.1. The LOGIC Block
    2. 17.2. Exercise 17-1: SPOT Finds a Spot
    3. 17.3. What's Next?
    4. 17.4. Exercise Solution
  23. 18. Title = Anything You Like
    1. 18.1. The VARIABLE Block
      1. 18.1.1. Exploring the VARIABLE Block
      2. 18.1.2. Reading from a VARIABLE
      3. 18.1.3. Writing to a VARIABLE
      4. 18.1.4. Storing Many Values
      5. 18.1.5. Solving the Example Problem
    2. 18.2. The CONSTANT Block
    3. 18.3. VARIABLE vs. CONSTANT
    4. 18.4. What's Next?
  24. 19. Basic Text
    1. 19.1. The TEXT Block
    2. 19.2. Exercise 19-1: Counting Characters
    3. 19.3. What's Next?
    4. 19.4. Exercise Solution
  25. 20. Basic Math
    1. 20.1. The MATH Block
    2. 20.2. Exercise 20-1: Calculate Total Degrees Traveled
    3. 20.3. What's Next?
    4. 20.4. Exercise Solution
  26. 21. Staying Alive
    1. 21.1. The KEEP ALIVE Block
    2. 21.2. Exercise 21-1: Loop Forever or Sleep?
    3. 21.3. What's Next?
    4. 21.4. Exercise Solution
  27. 22. Your Own Filing Cabinet
    1. 22.1. Introducing the FILE ACCESS Block
    2. 22.2. Exercise 22-1: Left, Right, Left
    3. 22.3. What's Next?
    4. 22.4. Exercise Solution
  28. 23. Calibration
    1. 23.1. The CALIBRATE Block
    2. 23.2. Put the CALIBRATE Block to Work
    3. 23.3. The Calibrate Sensors Tool
    4. 23.4. What's Next?
  29. 24. Motoring
    1. 24.1. The MOTOR Block
    2. 24.2. The RESET MOTOR Block
    3. 24.3. Exercise 24-1: True Readings
    4. 24.4. What's Next?
    5. 24.5. Exercise Solution
  30. 25. Messages
    1. 25.1. The BLUETOOTH CONNECTION Block
      1. 25.1.1. Some Preliminaries
      2. 25.1.2. Configuring a Connection
      3. 25.1.3. Initiating a Connection
      4. 25.1.4. Closing a Connection
    2. 25.2. The SEND MESSAGE Block
    3. 25.3. What's Next?
  31. 26. My Block Is Your Block
    1. 26.1. Creating a My Block
    2. 26.2. Exercise 26-1: The MyBlock Plug
    3. 26.3. You're Ready to Go!
    4. 26.4. Exercise Solution
  32. A. Math Basics for NXT
    1. A.1. Converting Between Degrees and Rotations
    2. A.2. Converting Degrees and Rotations into Distances
    3. A.3. The X/Y Coordinate System in NXT
  33. B. SPOT Building Instructions
  34. C. Image Editor
    1. C.1. Opening an Image
    2. C.2. Modifying an Image
    3. C.3. Saving an Image
    4. C.4. Using Your Image

Product information

  • Title: Lego Mindstorms NXT-G Programming Guide, Second Edition
  • Author(s):
  • Release date: June 2010
  • Publisher(s): Apress
  • ISBN: 9781430229766