part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Table of Contents About the Author About the Technical Reviewer Introduction Chapter 1: Introduction to Robotics Robotics Basics Linux and Robotics Sensors and GPIO Motion and Control Raspberry Pi and Arduino Project Overview The Robot Bill of Materials (BOM) Summary Chapter 2: An Introduction to Raspberry Pi Downloading and Installing Raspberry Pi OS Raspberry Pi OS with OpenCV The “Hard” Way The “Easy” Way Connecting Raspberry Pi Configuring Your Pi Users Securing Root Change the Default Username Going Headless Remote Access Remote Desktop with xrdp SSH with PuTTY Finding Your Device on a Network Summary Chapter 3: A Crash Course in Python Python Overview Downloading and Installing Python Python Tools The Python Shell The Python Editor The Zen of Python Writing and Running a Python Program Hello World Basic Structure Program Parts Indentation Comments Running a Program Programming in Python Variables Data Types Strings String Manipulation Numbers Lists Tuples Dictionaries None Type A Final Note on Variables Control Structures if Statements Loops for Loop while Loop Functions Defining a Function Passing Arguments Default Values Return Values Adding Functionality Through Modules Importing and Using Modules Built-In Modules Extended Modules Custom Modules Classes Creating a Class Planning Initial Sample Robot Class Initial Sample Robot Class Styling Blank Lines Commenting Naming Conventions Summary Chapter 4: Raspberry Pi GPIO Raspberry Pi GPIO Pin Numbering Connecting to the Raspberry Pi Limitations of Raspberry Pi’s GPIO Accessing GPIO with Python Simple Output: LED Example Hooking Up the Circuit Writing the Code Pulse Width Modulation (PWM) Hooking Up the Circuit Writing the Code Simple Input Push-Button Example Hooking Up the Circuit Writing the Code Sonic Rangefinder Example Hooking Up the Circuit Writing the Code Summary Chapter 5: Raspberry Pi and Arduino Raspberry Pi’s GPIO in Review Real-Time or Near-Real-Time Processing Analog Input Analog Output Arduino to the Rescue Using Arduino Installing the Arduino IDE Connecting an Arduino Programming Arduino The Arduino IDE Icons and the Menu Creating a New Sketch Saving a Sketch Opening Existing Sketches Board and Port Selection Cheating with Examples Using Tabs and Multiple Files Sketches Hello, Arduino Anatomy of a Sketch A Brief Introduction to the Arduino Language Including Other Files Variables and Data Types Characters and Strings The String Object Numbers Arrays Control Structures if and else while Loops for Loops Functions Working with Pins Digital Operations Analog Input Analog Output (PWM) Pulsing LED The Circuit The Code Objects and Classes Serial Connecting to Serial Sending Serial Data Receiving Serial Data Arduino to Pi and Back Again Installing PySerial Sending Data to the Raspberry Pi Sending Data to the Arduino Pinguino Setting Up the Circuit The Code Arduino Raspberry Pi Summary Chapter 6: Driving Motors Motors and Drivers Types of Motors DC Motors Brushless Motors Stepper Motors Servos Motor Properties Voltage Amperage Motors and Amps Motor Drivers Working with Motor Controllers Adafruit DC & Stepper Motor HAT Some Assembly Required Hooking Up the Motor Controller Using the Motor HAT Enabling I2C Installing the Library The Code Turning a Single Motor Turning Two Motors L298N Generic Motor Driver H-Bridge Motor Controller Using the L298N Arduino Code Hooking Up the L298N Turning One Motor Turning Two Motors Summary Chapter 7: Assembling the Robot Assembling the Chassis Choosing a Material The Whippersnapper Mounting the Electronics Wiring Mounting Sensors The Finished Robot Making the Robot Mobile The Plan Sensors Motors Behavior The Code Arduino Code Raspberry Pi Code Summary Chapter 8: Working with Infrared Sensors Infrared Sensors Types of IR Sensors Reflectance Sensors Line and Edge Detection Rangefinders Interrupt Sensors PIR Motion Detectors Working with IR Sensors Connecting an IR Sensor Mounting the IR Sensors The Code Arduino Code Python Code Understanding PID Control Control Loops Proportional, Integral, and Derivative Control Proportional Control Integral Control Derivative Control Bringing Them Together Implementing the PID Controller The Code Raspberry Pi Code Summary Chapter 9: An Introduction to OpenCV Computer Vision OpenCV Installing OpenCV Installing the Prerequisites Installing OpenCV with pip install Compiling OpenCV from Source Code Selecting a Camera Installing the Camera OpenCV Basics Working with Images Displaying an Image Capturing Images Opening an Image File Capturing Video Viewing the Camera Recording Video Reading Video from a File Image Transformations Flipping Resizing Working with Color Color Spaces Color Filters Blobs and Blob Detection Finding a Blob The Parameters The Filters filterByColor filterByArea filterByCircularity filterByInertia filterByConvexity Blob Tracking Ball-Chasing Bot Summary Chapter 10: Conclusion Types of Robotics Tools Software Choosing an IDE Design Software 2D Drawing Circuit Board Design 3D Design Hardware Basic Tools Specialty Tools Makerspaces Summary Index Learn how to use a Raspberry Pi in conjunction with an Arduino to build a basic robot with advanced capabilities. Getting started in robotics does not have to be difficult. This book is an insightful and rewarding introduction to robotics and a catalyst for further directed study. Fully updated to cover the Raspberry Pi 4 with its better processor and memory, discover new ways to work with Computer Vision. You'll be led step by step through the process of building a robot that uses the power of a Linux based computer paired with the simplicity of Arduino. You'll learn why the Raspberry Pi is a great choice for a robotics platform; its strengths as well as its shortcomings; how to overcome these limitations by implementing an Arduino; and the basics of the Python programming language as well as some of the more powerful features. With the Raspberry Pi you can give your project the power of a Linux computer, while Arduino makes interacting with sensors and motors very easy. These two boards are complimentary in their functions; where one falters the other performs admirably. The book also includes references to other great works to help further your growth in the exciting, and now accessible, field of smart robotics. As a bonus, the final chapter of the book demonstrates the real power of the Raspberry Pi by implementing a basic vision system. Using OpenCV and a standard USB web cam, you will build a robot that can chase a ball. What You'll Learn Install Raspbian, the operating system that drives the Raspberry Pi Drive motors through an I2C motor controller Read data through sensors attached to an Arduino Who This Book Is For Hobbyists and students looking for a rapid start in robotics. It assumes no technical background. Readers are guided to pursue the areas that interest them in more detail as they learn. Learn how to use a Raspberry Pi in conjunction with an Arduino to build a basic robot with advanced capabilities. Getting started in robotics does not have to be difficult. This book is an insightful and rewarding introduction to robotics and a catalyst for further directed study. You'll be led step by step through the process of building a robot that uses the power of a Linux based computer paired with the simplicity of Arduino. You'll learn why the Raspberry Pi is a great choice for a robotics platform; its strengths as well as its shortcomings; how to overcome these limitations by implementing an Arduino; and the basics of the Python programming language as well as some of the more powerful features. With the Raspberry Pi you can give your project the power of a Linux computer, while Arduino makes interacting with sensors and motors very easy. These two boards are complimentary in their functions; where one falters the other performs admirably. The book also includes references to other great works to help further your growth in the exciting, and now accessible, field of smart robotics. As a bonus, the final chapter of the book demonstrates the real power of the Raspberry Pi by implementing a basic vision system. Using OpenCV and a standard USB web cam, you will build a robot that can chase a ball -- Amazon