Professional Documents
Culture Documents
Siddharth Mankad
ust like chef Gusteau said in the movie Ratatouille, Anyone can cook! we could say, Anyone can prototype! Lets begin by simplifying the term physical computing. It definitely sounds too techie to a newbie. According to Wikipedia, physical computing, in the broadest sense means building interactive physical systems by the use of software and hardware that can sense and respond to the analogue world. In other words, we can make devices that use sensors as input and perform some action (physical or virtual) as output.
other processors too apart from the ones listed above. The Arduino board comes in many sizes for a varied number of applications, the most common being the Arduino Duemilanove. The Diecimila is the older version of the Duemilanove. Other form factors include Arduino LilyPad (for wearable computing; it can be sewn onto/into clothes), Arduino Nano (for use with breadboards), Arduino Mega (a more powerful variant of the Duemilanove), Arduino Pro (a cheaper version of the Duemilanove meant for advanced users), Arduino Pro mini, Arduino Fio and Arduino BT (for wireless applications; BT uses Bluetooth) and Arduino Serial (unlike the other boards, it uses a serial/RS-232 interface instead of the USB for hook-up to the computer). The Duemilanove board is suitable for starters. It is easy to use since its USB-based.
the fundamentals
The first thing is to get hold of the hardware. In India, you can get the board from feemo or rhydoLABZ. The cheapest way to assemble an Arduino is to use the breadboard. Here, a blank Arduino PCB with serial COM port is used and the components are soldered onto it. The parts list is available on the official Arduino site with the schematic. It is fairly easy to assemble. The Arduino board with serial COM port requires power (unlike the Duemilanove where
w w w. e f y m Ag . co m
open source
FileExamplesDigitalBlink. The code for blinking LED is listed below:
int ledPin = 13; // LED connected to digital pin 13 // The setup() method runs once, when the sketch starts void setup() an output: pinMode(ledPin, OUTPUT); } // the loop() method runs over and over again, // as long as the Arduino has power void loop() Fig. 2: The Arduino hardware { digitalWrite(ledPin, HIGH); set the LED on delay(1000); wait for a second digitalWrite(ledPin, LOW); set the LED off delay(1000); wait for a second } // // // // {
external power is an option). You can connect an AC-DC adaptor (~12V, with centre pin positive). The board can take up to 25V DC. Also, you will require an FTDI cable (serial-to-USB) if you do not have a COM port in your computer. Duemilanove users can just plugand-play after installing the drivers. The FTDI USB drivers are with the Arduino IDE in the drivers folder.
se. The Arduino hardware is shown in Fig. 2. The digital input/output (I/O) pins are where you can connect output devices like motors, LCDs, touchscreens and sensors for input. The analogue input pins are where input sensors and analogue input devices like potentiometers (pots) can be connected. The processorATmegais the brain of the entire operation. Download the Arduino IDE from the website and install it in your system if you havent already done so. Extract it. The Arduino can be programmed from Windows, Mac and Linux. Start the IDE and go to
Arduino source code contains the following sections: 1. The setup(), which runs only once (automatically) when the program starts running. 2. The loop(), which is an infinite loop that is triggered once setup() completes. 3. Other user-defined functions. In any program, the setup() and loop() are mandatory. Any extra libraries used will have to be imported using the import statement before the setup(). Coming back to the LED blinking example, the first line sets an integer variable with the value of the pin at which we have connected the LED. The pinMode function tells the ATmega whether the pin 13 (ledPin variables value) has an input or an output device connected to it. The first argument is the pin number. The LED is an output component, hence pinModes second argument would be output.
w w w. e f y m Ag . co m
1 0 2 Au g u s t 2 0 1 1 e l e c t ro n i c s f o r yo u
open source
Now we come to the loop(). The first line in loop(), digitalWrite sends voltage and current to the ledPin (pin 13) using the high argument (high means on). This turns the LED on. Then it gives a delay of 1000 milliseconds. This means that the LED remains on for 1000 milliseconds or 1 second. After that the low argument (line 3) turns off the current and voltage on the ledPin, and again (line 4) waits for a second. These four lines will run infinitely. Connect an LED to the board as shown in Fig. 3. Connect the positive of the LED (the longer leg) to digital pin 13 of ATmega chip and the other leg to the GND digital pin. Once the code is written, hit the Play button (or CTRL+R) to compile it. After compilation, the generated hex file has to be uploaded to the ATmega. Press FileUpload To I/O Board (or CTRL+U). The programmer section handles the burning of code into the ATmega chip. The bootloader on the ATmega kickstarts your loaded program. The result is a blinking LED.
taking it forward
The example is a simple demonstration of physical computing, though we did not use any input. You can now experiment with various sensors like the light dependent resistor (LDR) and say, make a program that dims the LED if the LDR is subjected to less light, and vice versa. Lots of interesting combinations of sensors and outputs, actions and reactions and a whole gamut of interactive devices can be built. The references, documentation and forums are avail-
able to help you out if you run into any issuesOpen Source Community! People have used this in robotics, aeromodeling, hobby projects and new media applications. The Arduino can control servo motors, stepper motors, LCD screens, etc. It can take inputs from pressure sensors, accelerometers, GPS modules, gyroscopes, tempera-
ture sensors, humidity sensors, etc. It can interface with XBee (wireless) and bluetooth modules too. Even a basic touchscreen (from the Nintendo DS) can be used for interaction. The screen is available readily and is cheap at close to Rs 700. The possibilities are immense. Whats more is, that you could mashup and combine sensors to come up with interesting new possibilities. All of this with an easy to use IDE and programming pattern. Examples of what people have done include making an unmanned aerial vehicle (UAV) and weather stations. The limit is purely your imagination.
The author is associated with the National Institute of Design
w w w. e f y m Ag . co m
1 0 4 Au g u s t 2 0 1 1 e l e c t ro n i c s f o r yo u