open source aug11
TRANSCRIPT
8/3/2019 Open Source Aug11
http://slidepdf.com/reader/full/open-source-aug11 1/3
open source
100 • August 2011 • electronics for you w w w . e f y m A g . c o m
Siddharth Mankad
Open Source Physical Computing
for BeginnersPyscl compug s o s mg s sous. Ee e auoplfom— plfom fo pyscl compug fo e beges
W s e auoplfom?
Arduino (pronounced as aar-do-we-
know) platform is a small and efcient
AVR development board for hobbyists.
It has been developed by Massimo
Banzi and the Arduino team. AVR
is the series of 8-bit RISC microcon-
trollers based on a modied Harvard
microcontroller architecture. The chips
used on the Arduino board include
the ATmega AVR family—ATmega8,
ATmega168, ATmega328 and the AT-
mega1280.
Since the Arduino platform is
Open Source, there have been manyclones, and many of these clones use
other processors too apart from the
ones listed above. The Arduino board
comes in many sizes for a varied num-
ber of applications, the most common
being the Arduino Duemilanove. The
Diecimila is the older version of the
Duemilanove. Other form factors in-
clude 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 us-
ers), Arduino Pro mini, Arduino Fio
and Arduino BT (for wireless applica-
tions; BT uses Bluetooth) and ArduinoSerial (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 it’s USB-based.
te fumels
The rst 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 ofcial
Arduino site with the schematic.
It is fairly easy to assemble.
The Arduino board with se-
rial COM port requires power(unlike the Duemilanove where
J
ust like chef Gusteau said in the
movie Ratatouille , “Anyone can
cook!” we could say, “Anyone can
prototype!” Let’s begin by simpli-
fying the term physical computing. It
denitely sounds too techie to a new-
bie. According to Wikipedia, physi-
cal 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 de-
vices that use sensors as input and per-
form some action (physical or virtual)as output.
Fig. 1: The Arduino board
8/3/2019 Open Source Aug11
http://slidepdf.com/reader/full/open-source-aug11 2/3
open source
102 • August 2011 • electronics for you w w w . e f y m A g . c o m
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 plug-
and-play after installing the drivers.
The FTDI USB drivers are with the
Arduino IDE in the ‘drivers’ folder.
Le’s ge ou s we
Here, the program ‘Blink’ is used to
explain, using the Duemilanove. Even
if the serial COM port version is usedthere will hardly be any difference per
se. The Arduino hardware is shown
in Fig. 2.
The digital input/output (I/O) pins
are where you can connect output de-
vices like motors, LCDs, touchscreens
and sensors for input. The analogue
input pins are where input sensors and
analogue input devices like potenti-
ometers (pots) can be connected. The
processor—ATmega—is the brain of
the entire operation.
Download the Arduino IDE from
the website and install it in your
system if you haven’t already done
so. Extract it. The Arduino can be
programmed from Windows, Macand Linux. Start the IDE and go to
File→Examples→Digital→Blink. 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() {
// initialize the digital pin as
an output:
pinMode(ledPin, OUTPUT);
}
// the loop() method runs over and
over again,
// as long as the Arduino has power
void loop()
{
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
}
Arduino source code contains thefollowing sections:
1. The setup(), which runs only
once (automatically) when the pro-
gram starts running.
2. The loop(), which is an innite
loop that is triggered once setup()
completes.
3. Other user-dened functions.
In any program, the setup() and
loop() are mandatory. Any extra li-
braries used will have to be imported
using the ‘import’ statement before the
setup().
Coming back to the LED blinking
example, the rst 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’ variable’s
value) has an input or an output device
connected to it. The rst argument is
the pin number. The LED is an output
component, hence pinMode’s secondargument would be output.
Fig. 2: The Arduino hardware
Fig. 3: Connecting the LED
8/3/2019 Open Source Aug11
http://slidepdf.com/reader/full/open-source-aug11 3/3
open source
104 • August 2011 • electronics for you w w w . e f y m A g . c o m
Related stuff and resources
Arduino has a large community and good support and documentation available on theinternet. The resources, references and links are below: www.arduino.cc (The Arduino Homepage) www.feemo.in (Feemo) www.rhydolabz.com (rhydoLABZ) http://www.arduino.cc/en/Main/StandaloneAssembly (Breadboard Arduino) http://lab.guilhermemartins.net/2009/05/06/paperduino-prints/ (Paperduino—make
Arduino on a cardboard)
Fig. 4: The Arduino IDE
Now we come to the loop(). The
rst 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 millisec-
onds. This means that the LED remainson 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
innitely.
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
le has to be uploaded to the ATmega.
Press File→Upload 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 pro-
gram. The result is a blinking LED.
tg fow
The example is a simple demonstration
of physical computing, though we did
not use any input. You can now ex-
periment 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 reac-
tions 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 issues—Open Source Community!
People have used this in robotics, aero-
modeling, 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.
What’s more is, that you could mash-
up 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 mak-
ing an unmanned aerial vehicle (UAV)
and weather stations. The limit is
purely your imagination.
The author is associated with the National Instituteof Design