Learn how to use the Kinect with the Arduino platform to create interesting gadgets as well as innovative art. The ten projects are carefully designed to build on your skills at every step. Starting with the Arduino and Kinect equivalent of "Hello, World," the authors will take you through a diverse range of projects that showcase the huge range of possibilities that open up when Kinect and Arduino are combined. Skip to main content Skip to table of contents. Advertisement Hide.
This service is more advanced with JavaScript available. You've done some Arduino projects, so what's next? Front Matter Pages i-xxii. Arduino Basics. Pages Kinect Basics. Kinect Remote Control. Kinect Networked Puppet. 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. 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. You will also learn how to use proximity sensors. You will use all these techniques to control a RC car with hand gestures. 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. 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.
Then you will learn how to write your own. This book has been intentionally built upon multi-platform, open source initiatives. 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. Web sites like Wolfram Alpha www.
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. 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 Arduino Uno 1 www. 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 , more than , Arduino boards see Figure 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 founders of the project, Massimo Banzi and David Cuartielles, named the project after Arduin of Ivrea, the main historical character of the town. 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 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. You can drag the Arduino application to your Applications folder, and then run from there. Pretty easy, right? Installation on Windows First, download the Windows. You will see a folder called arduino 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. After a while, it will fail. No problem. Windows will successfully install the board now. 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.
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 Board selection After this, select the serial device under the Serial Port option in your Tools menu.
If you are using Windows, the port is likely to be COM 3 or higher. Serial port 4 www. You will be using one of the classic Arduino examples for this test. Click the Open button on your toolbar and navigate to 1.
Then upload the sketch by clicking the Upload button the one with the arrow pointing right on your toolbar. If you succeeded in this, your Arduino is correctly set up, and you can move on to learning about the Arduino hardware and software. Opening the Blink example Arduino Hardware You can think of the Arduino board as a little brain that allows you to connect together a vast range of sensors and actuators.
Atmel AVR is an 8-bit single chip microcontroller developed by Atmel in Each one of them has been designed with a different purpose in mind and thus has different amount of pins and electronics on board see Figure The Arduino Uno is, at the time of writing, the simplest Arduino board to use.
For the rest of the book, whenever we refer to Arduino board, we actually mean an Arduino Uno unless explicitly stated we will also work with Arduino Nano and Arduino Lilypad in further chapters. In this way, if none of the board designs seem to satisfy your needs, or if you want to have access to cheaper boards, you can actually make your own Arduino-compatible board. If you want to know how to do this, get Arduino Robotics Apress, and you will learn all you need to know to make your own Arduino clone.
The architecture of the Arduino board exposes these pins so they can be easily connected to external circuits. Arduino pins can be set up in two modes: input and output.
Arduino digital pins top and analog pins bottom Digital Pins Arduino has 14 digital pins, numbered from 0 to In further chapters, you will learn how to set these pins to INPUT so you can read the state of a switch, electric pulses, and other digital signals. Six of these pins can also be used as pulse width modulation pins PWM.
Chapter 4 covers what this means and how to use PWM pins. The function of this device is to convert an analog input voltage also known as 7 www. The ATmega converter on your Arduino board has bit resolution, which means it will return integers from 0 to proportionally based on the potential you apply compared to the reference 5V.
An input potential of 0V will produce a 0, an input potential of 5V will return , and an input potential of 2. These pins can actually be set as input or output pins exactly as your digital pins, by calling them A0, A1, etc. If you need more than six digital input or output pins for a project, you can use your analog pins, reading or writing to them as if they were digital pins.
You will be using this trick in Chapter 10 when you need 16 digital input pins. Pull-Up Resistors Whenever you are reading a digital input from one of your Arduino pins, you are actually checking the incoming voltage to that pin.
Arduino is ready to return a 0 if no voltage is detected and a 1 if the voltage is close to the supply voltage 5V. You need to ensure that the incoming voltages are as close as possible to 0 or 5V if you want to get consistent readings in your circuit. However, when the pins are set to input, they are said to be in a high-impedance state, which means it takes very little current to move the pin from one state to another.
This can be used to make applications that take advantage of this phenomenon, such capacitive touch sensors or reading LEDs as photodiodes, but for general use this means that the state of a disconnected input pin will oscillate randomly between 1 and 0 due to electrical noise.
To avoid this, you need to somehow bias the input to a known state if no input is present. This is the role of the ATmega built-in pull-up resistors. Pull-up and pull-down resistors from Wikipedia Looking at Figure , you can see that whenever the switch is open, the voltage Vout, which is the voltage you will read at the input pin, is very near Vin, or 5V. When the switch is closed, all the current flows through the resistor to ground, making Vout very close to ground, or 0V.
In this way, your input pin is always driven to a consistent state very close to 0 or 5V. The pull-down resistor works the same way, but the signal will be biased or pulled down to ground when the switch is open and to 5V when the switch is closed.
There are a few official Arduino shields and a vast number of unofficial ones that you can find on the Internet see Figures and And the best thing, you can create your own Arduino shields by using an Arduino-compatible Protoshield or by printing your own PCB compatible with the Arduino design. Official Arduino shields 9 www. An IDE is basically a program designed to facilitate software development.
The Arduino IDE includes a source code editor a text editor with some useful features for programming, such as syntax highlighting and automatic indentation and a compiler that turns the code you have written into machine-readable instructions. But all you really need to know about the Arduino IDE is that it is the piece of software that will allow you to easily write your own Arduino sketches and upload them to the board with a single click.
Figure shows what the IDE looks like. Table offers a description of all the buttons you will find in the toolbar. New Creates a new sketch. Open Presents a menu of all the sketches in your sketchbook.
Clicking one will open it within the current window. Save Saves your sketch. Serial Monitor Opens the serial monitor. If these symbols look somewhat different from those in your Arduino IDE, you probably have an old version of the Arduino tools. At the time of writing, Arduino 1. You can still open. You need to match the baud rate on your serial monitor to the baud rate you specify in the Arduino sketch sending data. The baud rate is the number of symbol changes transmitted per second.
The serial monitor is very useful in the debugging of Arduino programs the process of finding and fixing the defects in the program so it behaves as expected. Arduino Serial Monitor You will make extensive use of serial communication throughout the book, as it is the main way to get Arduino to communicate with Processing and thus with the Kinect data.
When you write an Arduino sketch, you are implicitly making use of the Wiring library, which is included with the Arduino IDE. This allows you to make runnable programs by using only two functions: setup and loop.
As mentioned, the Wiring language is inspired by Processing, and the Arduino language structure is inherited from the Processing language, where the equivalent functions are called setup and draw , as you will see in Chapter 3. The setup Function The setup function is run only once, right after you upload a new sketch to the board, and then each time you power up your Arduino. You use this function to initialize variables, pin modes, start libraries, etc. This function is the core of most programs.
Then you pause the execution of the program for one second with the function delay. During this time, the LED will remain on. After this pause, you turn the LED off, again using the function digitalWrite but sending a LOW 0V signal instead, and then pause the program for another second. This code will loop continuously, making the LED blink. In more complex programs, you will declare, initialize, and use variables. Variables are symbolic names given to a certain quantity of information.
This means you will associate a certain piece of information with a symbolic name or identifier by which you will refer to it. The data type specifies the kind of data that can be stored in the variable and has an influence in the amount of memory that is reserved for that variable. Table lists some of the data types you will use throughout this book.
Table Arduino Fundamental Data Types Name Description Size Range char Character or small integer 1byte Signed: to Unsigned: 0 to boolean Boolean value true or false 1byte True or false int Integer 4bytes Signed: to Unsigned: 0 to 13 www. In the following lines, you declare an integer, a character, and a Boolean variable: int myInteger; char myLetter; boolean test; This code has declared the variables, but their value is undetermined.
In some cases, you want to declare the variable and set it to a default value at the same time. This is called initializing the variables. In other cases, you want to declare the variables first and initialize them later. If you declare your variable outside of any function, it will be considered a global variable and will be accessible from anywhere in the code.
If you declare your variable within a function, the variable will be a local variable and will only be accessible from within the same function. You have declared and initialized the integer ledPin at the beginning of your program, outside of any function, so it is considered a global variable visible from within the other functions in the code.
The variable myOtherPin, on the other hand, has been defined within the setup function. Your First Arduino Project You are going to write an example Arduino sketch involving all the elements you just learned in the previous sections. This is only a very first step in the development of an Arduino project, but it will be enough to summarize this chapter on Arduino basics.
You are going to build a very simple circuit first, and then you will program it using your Arduino IDE.
You will need your Arduino board, a breadboard, an LED, a ohm resistor, a potentiometer, and some wires to build this example. Using a solderless breadboard, you can easily prototype electronics by plugging elements together. As the elements are not soldered to the board, the board can actually be reused as many times as you want see Figures and Bredboard connection diagram Figure Project sketched on a breadboard Note that the pins flanked by blue and red lines on your breadboard the top two rows and the bottom two rows in Figure are connected together horizontally, so you can use them to provide 5V and ground to all the elements on the project.
The other pins are connected in vertical strips broken in the middle. Building the Circuit Try to replicate this circuit on your breadboard and connect it to the Arduino as you see happening in Figure The LED is connected to analog pin 11, and the middle pin of the potentiometer is connected to analog pin 0.
Note that the LED has a shorter leg cathode , which needs to be connected to ground. The longer one is connected to the resistor. If you are curious about the functioning of LEDs and why you are using a ohm resistor, there is a whole section on resistors in Chapter 7.
A potentiometer is basically a variable resistor that you control by turning the knob. You acquire the values coming from the potentiometer from Arduino and use these values to drive the brightness of the LED.
All of this is done in the Arduino code. Programming the Arduino Now you are going to write the code that will permit you to drive the LED by turning your potentiometer. You will use serial communication to check the values that you are getting from the potentiometer in runtime using the Serial Monitor. First, you declare a global integer variable called ledPin that defines the LED pin number during the execution of the program.
Your first Arduino project 17 www. You initialize the variable to this value by using the analogRead function and specifying A0 Analog 0 as your pin. If you were to read analog pin 1, you would write A1, and so on. Then you print the value from the potentiometer to the serial buffer using the function Serial. If you open the Serial Monitor while the program is running, you will see that the values coming from the potentiometer range from 0 to You want to use this value to set the brightness of your LED, but you have stated that the scope of the brightness needs to be in a range of 0 to The solution to this issue will be mapping the values of the potentiometer from its range to the range of the potentiometer.
You will use this technique very often in your projects; luckily, Arduino has a function to perform this operation called map. The map function takes five arguments: map value, fromLow, fromHigh, toLow, toHigh.
The argument value is the current value to be mapped. In your case, your LED brightness needs to be defined as map sensorValue,0,,0, , so if the sensor value is , the LED brightness is The map function will always return an integer, even in the case that the mapping would result in a floating point number.
Circuit Diagrams We just described the circuit using photos and text. But when we get to more complicated circuits, this will not be enough. The way circuits should be represented is with circuit diagrams, or schematics.
Circuit diagrams show the components of a circuit as simplified standard symbols and the connections between the devices. There are numerous software packages that facilitate the drawing of schematics, but there is one designed to be used by non-engineers, and it works nicely with Arduino projects: Fritzing.
Fritzing has a graphical interface that allows the user to build the circuit as in the physical world, connecting together breadboards, Arduinos, LEDs, resistors, etc.
Then you turn this visual representation into a circuit diagram just by changing the view, as shown in Figures and Breadboard view of your project in Fritzing Figure Schematics view of your project in Fritzing 19 www.
There are several international standards for these graphical symbols. In this book, we will use ANSI in all the circuit diagrams and symbols. Table is a list of some electronics symbols that you will see used in this book and some of the IEC equivalents for reference.
One of the advantages of Arduino is that it makes for an easy introduction to electronics for beginners, but if you are completely new to electronics, here are some basic concepts. AC is actually cheaper to produce and transmit from the power plants to your home.
That is the reason why all the plugs in our households give us alternating current. But AC is also more difficult to control, so most electronic devices work with a power supply that converts AC into DC. Every time we speak about electricity or current in the book, we are referring to DC.
Ohms Law Electricity, or electrical current is, very generally, the movement of electrons through a conductor. The intensity I of this current is measured in amperes A. The force pushing the electrons to flow is called voltage, which is the measure of the potential energy difference relative between the two ends of the circuit.
Voltage is measured in Volts, or V. The conductor through which the electrons are flowing will oppose some resistance to their passage. Georg Ohm published a treatise in describing measurements of voltage and current flowing through circuits. The constant of proportionality is called resistance R.
Resistance is then the measure of the opposition to the passage of an electric current through an element. The opposite of resistance is conductance G. This, in turns, lets you estimate how long your project will run on a set of batteries.
Summary This first chapter has taken you through an overview of the Arduino platform in which both the Arduino hardware and software have been thoroughly analyzed. Your Arduino board should be properly configured now, the Arduino IDE should be installed on your computer, and you should be communicating seamlessly with your board via USB. You have had a brief refresher course on basic electrical concepts, and you have warmed up with a couple of examples. If this is your first contact with Arduino, you might want to consider having a look at some other titles like Beginning Arduino Apress, before you go deeper into this book, or at least have one at hand just in case.
You still have to go through some fundamental concepts about the other cornerstone of this book: the Kinect.
The Kinect is the second pillar of this book, so we will spend this chapter getting you acquainted with it. In the following pages, you will learn the story of this groundbreaking device, its hardware, software, and data streams. You will learn what a structured-light 3D scanner is and how it is implemented in the Kinect sensor.
You will learn about the different data you can acquire from your Kinect such as RGB, infrared, and depth images , and how they are combined to perform motion tracking and gesture recognition. Welcome to the world of Kinect!
The Kinect 23 www. But maybe you already have a Kinect device that you are using with your Xbox , or you are planning to buy the Kinect together with an Xbox You will need the AC power supply to connect your Kinect to an electrical outlet, and to convert the special USB plug to a standard USB that you will be able to plug to your computer Figure Unlike other game controllers, the Kinect connection was an open USB port, so it could potentially be connected to a PC.
They convert a well-known and predictable API application programming interface to the native API built into the hardware, making different devices look and behave similarly. Think of drivers as the translators between the hardware and the application or the operating system using it. The release of the open source drivers stirred a frenzy of Kinect application development that caught the attention of the media. The amazed public could see a growing number of new applications appear from every corner of the world.
Official Frameworks But the Kinect hackers were not the only ones to realize the incredible possibilities that the new technology was about to unleash. The companies involved in the design of the Kinect soon understood that the Kinect for Xbox was only a timid first step toward a new technological revolution—and they had no intention of being left behind. In February , it released a commercial version, accompanied by the Kinect for Windows device. And this is where we stand now. Laptops with integrated Kinect-like cameras are most probably on their way.
This is only the beginning of a whole range of hardware and applications using the technology behind Kinect to make computers better understand the world around them. It also contains an LED light, a three-axis accelerometer, and a small servo controlling the tilt of the device. This might not sound very impressive, but you need to remember that the magic happens in the depth sensor, which is completely independent of the RGB camera.
The two depth sensor elements, the IR projector and IR camera, work together with the internal chip from PrimeSense to reconstitute a 3D motion capture of the scene in front of the Kinect Figures and They do this by using a technique called structured-light 3D scanning, which we will discuss in depth at the end of this chapter.
The IR camera also uses a VGA resolution x pixels with bit depth, providing 2, levels of sensitivity. Kinect hardware 26 www. If the objects stand too close to the sensor, they will not be scanned and will just appear as black spots; if they are too far, the scanning precision will be too low, making them appear as flat objects.
If you are using the Kinect for Windows device, the range of the camera is shorter, from 40cm to 3m. Kinect Capabilities So what can you do with your Kinect device and all of the hi-tech stuff hidden inside? Once the Kinect is properly installed and communicating with your computer, you will be able to access a series of raw data streams and other capabilities provided by specific middleware.
This is also covered in Chapter 3. This VGA image has a precision of 11 bits, or different values, represented graphically by levels of grey from white to black 0. In Chapter 3, you will learn how to access and display the depth image from Processing using the OpenNI framework and how to translate the gray scale image into real space dimensions.
Without getting into what a logarithmic scale is, you should know that the precision of the depth sensing is lower on objects further from the Kinect sensor. Hand and Skeleton Tracking After the depth map has been generated, you can use it directly for your applications or run it through a specific middleware to extract more complex information from the raw depth map.
Chapter 4 will teach you how to use hand tracking to control LED lights through an Arduino board. Chapter 6 will teach you how to work with skeleton tracking. The algorithms that NITE or other middleware use to extract this information from the depth map fall way beyond the scope of this book, but if you are curious, you can read Hacking the Kinect by Jeff Kramer et al Apress, , in which you will find a whole chapter on gesture recognition.
Kinect Drivers and Frameworks In order to access the Kinect data streams, you will need to install the necessary drivers on your computer. Because of the rather complicate story of this device, there are a series of choices available that we will detail next. Access to the microphones is being worked on. OpenNI abstract layered view courtesy of PrimeSense Because OpenNI breaks the dependency between the sensor and the middleware see Figure , the API enables middleware developers to develop algorithms on top of raw data formats, independent of the sensor device that is producing the data.
In the same way, sensor manufacturers can build sensors that will work with any OpenNI-compliant application. Then Microsoft added a motor and a three-axis accelerometer to the design. PrimeSense is a fabless fabrication-less semiconductor company. It makes its revenue by selling hardware and semiconductor chips while outsourcing fabrication.
This is exactly the way in which it was involved in the development of the Kinect with Microsoft. PrimeSense then sells its technology to manufacturers such as ASUS and other computer or television manufacturers. But for this market to be developed, there needs to exist an ecosystem of people creating natural interaction-based content and applications. PrimeSense created OpenNI as a way to empower developers to add natural interaction to their software and applications so this ecosystem would flourish.
The most useful features come from the skeleton and hand tracking capabilities. Not all developers have the knowledge, time, or resources to develop these capabilities from scratch, as they involve advanced algorithms.
PrimeSense decided to implement these capabilities and distribute them for commercial purposes but keep the code closed, and so NITE was developed.
OpenNI is open source and for commercial use. NITE is not open source, but it is also distributed for commercial use. Without a doubt, there will be other middleware developed by third parties in the future that will compete with OpenNI and NITE for natural interaction applications. In Chapter 3, you will learn how to download OpenNI and NITE, and you will start using them to develop amazing projects throughout the rest of the book.
From February , the Kinect for Windows includes a new sensor device specifically designed for use with a Windows-based PC and a new version of the SDK for commercial use. This technique is used in many industrial applications, such as production control and volume measurement, and involves highly accurate and expensive scanners.
Kinect is the first device to implement this technique in a consumer product. Structured-Light 3D Scanning Most structured-light scanners are based on the projection of a narrow stripe of light onto a 3D object, using the deformation of the stripe when seen from a point of view different from the source to measure the distance from each point to the camera and thus reconstitute the 3D volume. This method can be extended to the projection of many stripes of light at the same time, which provides a high number of samples simultaneously Figure This captured image is passed on to the onboard PrimeSense chip to be translated into the depth image Figure Kinnect IR coding image detail Figure Depth map left reconstituted from the light coding infrared pattern right 32 www.
ASUS is also creating an online store for Xtion applications where developers will be able to sell their software to users. It was not the intention of the authors to give you a detailed introduction to all of the technical aspects of the Kinect device; we just wanted to get you acquainted with the amazing sensor that will allow you to build all the projects in this book—and the ones that you will imagine afterwards.
In the next chapter, you will learn how to install all the software you need to use your Kinect. Then you will implement your first Kinect program. Now you are the controller! Processing and Arduino IDEs side by side 35 www. Kinect is no exception to this, and thus Processing is able to talk to Kinect devices through several libraries available from its web site.
Processing is also capable of talking to Arduino using serial communication. Throughout the rest of the book, you will be creating Kinect and Arduino projects that talk through Processing and Simple-OpenNI, so the understanding of these techniques is essential to the development of any of the upcoming projects. One of the stated aims of Processing is to act as a tool to get non-programmers started with programming.
Initially developed to serve as a software sketchbook and to teach fundamentals of computer programming within a visual context, Processing also has evolved into a tool for generating finished professional work. Today, there are tens of thousands of students, artists, designers, researchers, and hobbyists who use Processing for learning, prototyping, and production. Processing is based in Java, one of the most widespread programming languages available today.
Java is an object-oriented, multi-platform programming language. The code you write in Java is compiled into something called bytecode that is then executed by the Java Virtual Machine living in your computer. This allows the programmer you to write software without having to worry about the operating system OS it will be run on. As you can guess, this is a huge advantage when you are trying to write software to be used in different machines.
Processing programs are called sketches because Processing was first designed as a tool for designers to quickly code ideas that would later be developed in other programming languages. As the project developed, though, Processing expanded its capabilities, and it is now used for many complex projects as well as a sketching tool.
Installing Processing Installing Processing is definitely not much of a hassle. Once you have downloaded the. If you run it, you should get a window like the one depicted in Figure Processing will work on any OS from wherever you store it. On Windows, Program Files would seem like a good place for a new program to live. There is a console at the bottom of the Processing IDE; a message area that will warn you about errors in the code and at runtime; a text editor where you will write your code; plus a tab manager and a toolbar at the top of the IDE.
The Processing toolbar has a distribution of buttons similar to Arduino, yet with some differences see Figure The New, Open, and Save buttons play the same roles as in Arduino. But instead of having Verify and Upload buttons at the left, there are Run and Stop buttons. You might have guessed what they are for, but just in case, the Run button will run your application and the Stop button will halt it.
There is another button called Export PApplet; pressing it will convert the Processing code into Java code and then compile it as a Java Applet, which can be embedded in a web browser. The Standard button on the right side of the toolbar is used to change the mode from Standard to Android this is for Android Application development, and we are not going to get anywhere near Android Apps in this book, so you can forget about it.
Your first Processing sketch will get you acquainted with the basic structure on a Processing program. Processing Variables Variables are symbolic names used to store information in a program. There are eight primitive data types in Java, and they are all supported in Processing: byte, short, int, long, float, double, boolean, and char.
A detailed explanation of each one of these data types would be beyond the scope of this book, but we will state some general rules. Integers int will be used to store positive and negative whole numbers this means numbers without a decimal point, like 42, 0, and An integer variable can store values ranging from - 2,,, to 2,,, inclusive. If you need to store larger numbers, you need to define your variable as a long. Whenever you need more precision, you will be using floating-point numbers, or floats, which are numbers with a decimal place The data type double works the same way as float, but it is more precise.
In general, Processing encourages the use of floats over doubles because of the savings in memory and computational time. The data type boolean stores two values: true and false.
It is common to use booleans in control statements to determine the flow of the program. You will use this data type when you want to display or work with text. Control a drawing robot using a Kinect-based tangible table. Remote-controlled Vehicle.
Use your body gestures to controla smart vehicle. Biometric Station. Use the Kinect for biometric recognition and checking Body Mass Indexes. Learn how to use the Arduino LilyPad to build a wearable 3D modelling interface. Build a turntable scanner and scan any object using only one Kinect. Delta Robot. Build and control your ownfast and accurate parallel robot.
Table of Contents1. Arduino Basics 2. Kinect Basics 3. Interfacing Arduino and Kinect through Processing 4. Hello World: LED-me 5. Gesture-based Remote Control 6.
0コメント