ebook img

Arduino and Kinect Projects: Design, Build, Blow Their Minds PDF

411 Pages·2012·79.23 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Arduino and Kinect Projects: Design, Build, Blow Their Minds

www.it-ebooks.info For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. www.it-ebooks.info Contents at a Glance Contents..................................................................................................................vii About the Authors.................................................................................................xvii About the Technical Reviewer.............................................................................xviii Acknowledgments.................................................................................................xix Introduction............................................................................................................xx (cid:1) Chapter 1: Arduino Basics...................................................................................1 (cid:1) Chapter 2: Kinect Basics....................................................................................23 (cid:1) Chapter 3: Processing........................................................................................35 (cid:1) Chapter 4: Arduino and Kinect: “Hello World”...................................................61 (cid:1) Chapter 5: Kinect Remote Control......................................................................77 (cid:1) Chapter 6: Kinect Networked Puppet.................................................................99 (cid:1) Chapter 7: Mood Lamps...................................................................................133 (cid:1) Chapter 8: Kinect-Driven Drawing Robot.........................................................167 (cid:1) Chapter 9: Kinect Remote-Controlled Vehicles................................................207 (cid:1) Chapter 10: Biometric Station..........................................................................243 (cid:1) Chapter 11: 3D Modeling Interface..................................................................279 (cid:1) Chapter 12: Turntable Scanner........................................................................309 (cid:1) Chapter 13: Kinect-Controlled Delta Robot......................................................343 Index.....................................................................................................................385 v www.it-ebooks.info (cid:1) INTRODUCTION Introduction If you've done some Arduino tinkering and wondered how you could incorporate the Kinect in your projects — or the other way around — this book is for you. If you haven’t actually done any tinkering but you are looking for a good way to get started, this book might also be for you. Even though this is not intended as an introductory book, we have tried to assume as little knowledge from the reader as possible, starting from the installation of every tool you will be using and thoroughly explaining every new concept appearing in the book. The Structure of This Book This is a practical book. As such, you are going to be driven through a series of projects evolving from simple to complex, learning all you need to know along the way. The book starts with three introductory chapters oriented to getting you acquainted with Arduino, Kinect, and Processing in the least amount of time possible so you can go straight into building cool projects. From Chapter 4, you will be led through a series of 10 fun projects increasing in complexity, starting with the Arduino and Kinect equivalent of "Hello World" and finishing with the construction and programming of a Kinect-driven delta robot. The Content of the Chapters Each chapter will lead you step-by-step through the construction of the physical project, the building of the necessary circuits, the programming of the Arduino board, and the implementation of the Processing programs that connect the Kinect data to your Arduino board. Most projects will involve the implementation of two separate programs, the Arduino program and the Processing program. Arduino code will be displayed in bold monospace typeface, like this: digitalRead(A0); // This is Arduino Code Processing programs will be written in normal monospace font style, like this: fill(255,0,0); // This is Processing Code In each chapter, you will be introduced to the specific concepts and techniques that you will need to build that particular project—and probably some of the following ones. If you are an experienced programmer, you might want to read this book non-sequentially, starting by the project that interests you the most. If you are a programming beginner, you will find it easier to start with the first project and build up your knowledge as you progress through the book. This is a list of topics that will be introduced in each chapter, so if you are interested in a specific concept you can jump straight to the right project. • Chapter 1: You will learn everything you need to know about the Arduino platform, you will install the necessary drivers and software, and you will write your first Arduino program. • Chapter 2: This chapter will help you discover what’s inside that amazing new device that has changed human-computer interfaces: the Kinect. xx www.it-ebooks.info (cid:1) INTRODUCTION • Chapter 3: You will discover the Processing programming language and IDE. You will install Processing, build your first Processing programs, and learn a great deal about working in 3D. • Chapter 4: You will learn about communicating with Arduino and Kinect through serial, you will develop your own communication protocol, and you will use hand tracking for the first time. You will also learn how to use pulse width modulation and how to work with LEDs and light sensors. • Chapter 5: This chapter will teach you to hack a remote control and use body gestures to control your TV set. You will learn how to use relays and how to build a circuit on a prototyping shield. You will even develop your own gesture recognition routine. • Chapter 6: You will learn to work with servos and how to communicate through networks and over the Internet. You will also use Kinect’s skeleton tracking capabilities to drive a puppet with your body gestures. • Chapter 7: The Arduino Nano and the XBee wireless module will be introduced in this chapter. You will also learn all about resistors and color LEDs. You will take the skeleton tracking to three dimensions and use it to control a series of lamps responding to your presence. • Chapter 8: Przemek Jaworski has contributed this amazing drawing arm project. In this chapter, you will work with Firmata, a library that allows you to control the Arduino from Processing without the need to write any Arduino code. You will also learn how to build a tangible table to control your robotic arm. • Chapter 9: You will be introduced to DC motors and how to control them using H- bridges. You will also learn how to use proximity sensors. You will use all these techniques to control a RC car with hand gestures. • Chapter 10: This project will teach you how to hack a bathroom scale to provide user weight data wirelessly. You will learn how to acquire data from a seven- segment LCD display, and you will then combine the data with the Kinect skeleton tracking to implement user recognition and body mass index calculation. • Chapter 11: You will build a wireless, wearable circuit on a glove using the Arduino LilyPad, flex sensors, and an XBee module. You will then implement your own simple computer-assisted design (CAD) software, and you will use your wireless interface to draw 3D geometries by moving your hand in space. • Chapter 12: This chapter will teach you to parse, transform, and recompose raw point clouds in order to perform 360-degreee scans of objects using just one Kinect and a turntable that you will build. Then you will learn how to write your own .ply file export routine and how to import the point data into Meshlab to prepare it to be 3D printed or rendered. • Chapter 13: This final project will teach you the basics of inverse kinematics and how to use all the techniques from throughout the book to build a Kinect- controlled delta robot. This book has been intentionally built upon multi-platform, open source initiatives. All the tools utilized in the book are free and available for Mac OSX, Windows, and Linux on commercial licenses. Because of the three-dimensional nature of the data that you can acquire with the Kinect, some of the more advanced projects rely on the use of trigonometry and vector math. We have tried to cover the necessary principles and definitions, but if your mathematical skills are somewhat rusty, you might want xxi www.it-ebooks.info (cid:1) INTRODUCTION to consider having a reference book at hand. John Vince’s Mathematics for Computer Graphics (Springer, 2006) is an amazing resource. Web sites like Wolfram Alpha (www.wolframalpha.com) or mathWorld (http://mathworld.wolfram.com) can be helpful as well. Every chapter will include the necessary code to make the project work. You can copy this code from the book or you can download the necessary files from Apress (www.apress.com) or the book’s web site (www.arduinoandkinectprojects.com). If you need to contact the authors, you can find us via the following addresses: • Enrique Ramos Melgar: [email protected] • Ciriaco Castro Díez: [email protected] • Przemek Jaworski: [email protected] xxii www.it-ebooks.info C H A P T E R 1 (cid:1) (cid:1) (cid:1) Arduino Basics by Enrique Ramos This first chapter is dedicated to Arduino, one of the two cornerstones of this book. The following pages cover the basics of the Arduino hardware and software. By the end of the chapter, you will have installed the platform on your computer and you will have programmed two examples using the Arduino integrated development environment (IDE). The structure of an Arduino sketch will be analyzed and each function explained. You will learn about the Arduino input and output pins. You will also learn the basic concepts of electricity, circuits, and prototyping techniques that you will be using throughout the book. It is highly likely that this is not the first book on Arduino that you have held in your hands. If you are an experienced Arduino user, you should consider reading these pages as a refresher. If you are a complete beginner, read carefully! Figure 1-1. Arduino Uno 1 www.it-ebooks.info CHAPTER 1 (cid:1) ARDUINO BASICS What is Arduino? Arduino is an open source electronics prototyping platform composed of a microcontroller, a programming language, and an IDE. Arduino is a tool for making interactive applications, designed to simplify this task for beginners but still flexible enough for experts to develop complex projects. Since its inception in 2005, more than 200,000 Arduino boards (see Figure 1-1) have been sold, and there is a rapidly increasing number of projects using Arduino as their computing core. The Arduino community is vast, and so is the number of tutorials, reference books, and libraries available. Being open source means that there are Arduino clones that you can choose for your projects. Advanced Arduino users are constantly developing shields for the available Arduinos as well as completely new Arduino- compatible boards specializing in different tasks. The intentional simplicity of approach to the Arduino platform has permitted an access to physical computing for people who would have never thought of using or programming a microcontroller before the Arduino/Wiring era. A Brief History of Arduino Arduino was born in 2005 at the Interaction Design Institute Ivrea, Italy, as a fork of the open source Wiring Platform. The founders of the project, Massimo Banzi and David Cuartielles, named the project after Arduin of Ivrea, the main historical character of the town. Hernando Barragán, a student at the same Institute, along with Diego Gonzalez Joven, had developed Wiring in 2003 as his master’s thesis, which was supervised by Massimo Banzi and Casey Reas (one of the initiators of Processing). The idea behind Wiring was to allow an easy introduction to programming and sketching with electronics for artists and designers—in a similar mindset in which Casey Reas and Ben Fry had developed Processing some years earlier (you will learn more on the history of Processing in Chapter 3). Arduino was built around Wiring but developed independently from 2005. The two projects are still very much alive, so everything you will be doing in this book with Arduino could also be done with Wiring boards and IDE. Installing Arduino The first thing you need to do if you want to work with Arduino is to buy an Arduino board and a standard USB cable (A-to-B plug if you are using an Arduino Uno). Well, of course you will need more than this if you want to build any reasonable useful application, but for the moment you’ll just work with the bare essentials. Arduino runs on Windows, Mac OS X, and Linux, so there’s a version of Arduino for you whatever your OS. Go to the Arduino software web site at http://arduino.cc/en/Main/Software and download the version of the software compatible with your system. If after reading the following sections you are still having trouble with the installation, you can have more detailed information at http://arduino.cc/en/Guide/HomePage. Installation on Mac OS X After you have downloaded the .zip file, uncompress it. You can drag the Arduino application to your Applications folder, and then run from there. Pretty easy, right? 2 www.it-ebooks.info CHAPTER 1 (cid:1) ARDUINO BASICS If you are using a board older than Arduino Uno (Duemilanove, Diecimila, or older), you need to install the drivers for the FTDI chip on the board. You can find the drivers and the instructions at http://www.arduino.cc/en/Guide/MacOSX. Installation on Windows First, download the Windows .zip file and uncompress it. You will see a folder called arduino-1.0. This is your Arduino folder and you need to store it somewhere in the computer from where you can later run the program. The Program Files folder would seem like a reasonable place for the Arduino software, but feel free to choose an alternative location. You need to install the Arduino drivers before you can start working with your board. Assuming you are installing an Arduino Uno, follow these steps: • Plug your board to your computer, and wait for Windows to start the driver installation process. After a while, it will fail. No problem. • Click Start menu and open the Control Panel. • Go to System and Security, then System and then Device Manager. • Find the Arduino Uno port listed under Ports (COM & LPT). • Right-click on it, and choose “Update Driver Software,” selecting “Browse my Computer for Driver Software.” • Finally, navigate and select the Arduino Uno’s driver file named ArduinoUNO.inf located in the Drivers folder of the Arduino software folder you have just downloaded. Windows will successfully install the board now. Installation on Linux If you are working on Linux, the installation process is slightly different depending on your Linux distribution, and unfortunately we don’t have the space to detail all of them in this book. You can find all the information you need at http://www.arduino.cc/playground/Learning/Linux. Testing the Arduino Once you have installed the Arduino software and drivers, you need to perform a little test to make sure that everything is working properly. Arduino has a built-in LED connected to pin 13, so you can actually test the board without having to connect any extra hardware to it. Among the numerous Arduino examples included with the Arduino IDE, there is an example called Blink that makes this built-in LED to blink every second. You will learn more about pins, LEDs, and Arduino code in the following sections, but for the moment, you are going to use this example as a way to find out if your Arduino is communicating properly with your computer and if the sketches can be uploaded to the board. Connect your Arduino board to your computer and run the Arduino software. On the Tools menu, select Board, and make sure that the right kind of board is selected. In our case, we want to check that the Arduino Uno board is ticked (see Figure 1-2). 3 www.it-ebooks.info CHAPTER 1 (cid:1) ARDUINO BASICS Figure 1-2. Board selection After this, select the serial device under the Serial Port option in your Tools menu. If you are working on Mac OS X, the port should be something with /dev/tty.usbmodem (for the Uno or Mega 2560) or /dev/tty.usbserial (for older boards) in it (see Figure 1-3). If you are using Windows, the port is likely to be COM 3 or higher. Figure 1-3. Serial port 4 www.it-ebooks.info

Description:
If you've done some Arduino tinkering and wondered how you could incorporate the Kinect - or the other way around - then this book is for you. The authors of Arduino and Kinect Projects will show you how to create 10 amazing, creative projects, from simple to complex. You'll also find out how to inc
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.