You are on page 1of 15

Arduino

Programming Micro-Controllers

Overview
Before we begin it is important to have an understanding of the
Arduino development environment. In general the Arduino version
of the Processing IDE does a number of things that makes it easier
to program the Arduino. Arduino's IDE allows an individual project,
or sketch, to contain multiple files. Each of the files within a sketch
is displayed in aseparatetab.
Tabsfor a file with an extension of .pde have alabel that contains
thename of the file withoutits extension. On the other hand tabs
for files with any other extension are labeled withthe entire file
name, including the extension.

http://openhardwareplatform.blogspot.com/2011/03/inside-arduinobuild-process.html

The Arduindo IDE


During the build processthe Arduino IDE performs four major
tasks:
1. Combine Files:The .pde files are contatinated together.
2. Transformations: Adds function prototypes and #include
statement.
3. Compile Code: Each.c and .cppis compiled into .o files.
4. Linking: The .o files are linked together with library files.

1. Combine Files
The first step in the build processinvolvesconcatenatingthe
.pdefiles into a single program. You should keep in mind that
whenyoubuilda sketch, the processes are performed against
copies of your files that are placed in a temporary directory. On
the other hand when you "Upload" a sketch, the build process
occurs within the applet directory - a subdirectory of the sketch.
The
name
of
the
file
that
is
created
during
theconcatenationprocess is called {sketchName}.cpp; where
{sketchName} is the name of your "primary" .pde file.

2. Transformations
The Arduino environment makes a few alterations, or
transformations, to your code before it is compiled. The only code
that is altered during Arduino's preprocessing is the concatinated
version of the .pde files ({sketchName}.cpp). This .cpp file is altered
in two ways.First off Arduino adds the following line of code before
the first line of any of your code, but after any comments:
#include "WProgram.h"
This line of code imports (includes) a header file that contains some
key Arduino definitions and additional includes that make the world
of coding for Arduino hardware much easier.
The final step of the transformation is to append the contents of the
main.cxx filefor the current target to the bottom of the
{sketchName}.cpp file.

3. Compile Code
Once the build process completes the Combine Files and
Transformations steps, itcreates an "includePaths" List that is used for
each components it compiles.
The include path for the compilation process will consist of the
sketch's
directory,
the
target
directory
({ArduinoPath}\hardware\arduino\cores\arduino), and the AVR include
directory{ArduinoPath}\hardware\tools\avr\avr\include), as well as
any
libraries
({ArduinoPath}\libraries)
referenced
in
the
{sketchName}.cppfile.

The Arduino IDE individually submits each of the .s, .c and .cpp files that are
part of the sketch, including the {sketchName}.cpp file, to AVR-GCC for
compilation.The options used by the Arduino IDE to compile the these .s, .c,
and .cpp files are shown below.
.s Files
avr-gcc

-c
-g

-assembler-with-cpp
mmcu={boardPreferences.get("build.mcu")}
DF_CPU={boardPreferences.get("build.f_cpu")
.cpp Files
}
avr-gcc
-c
-DARDUINO={Base.REVISION}
-g
-I
-Os
-o
-w
-fno-exceptions
-ffunction-sections
-fdata-sections
.c Files
avr-gcc
-c
mmcu={boardPreferences.get("build.mcu")}
-g
-Os
DF_CPU={boardPreferences.get("build.f_cpu")}
-w
-DARDUINO={Base.REVISION}
-ffunction-sections
-I
-fdata-sections
-o
mmcu={boardPreferences.get("build.mcu")}
DF_CPU={boardPreferences.get("build.f_cpu")
}
-DARDUINO={Base.REVISION}
-I

4. Linking
In this context linking is used to describe the process of combining the
object and archive files into a single .hex file. In order to accomplish this
the Arduino IDE goes through three distinctive stages; ELF File Creation,
EEP File Creation and HEX File Creation.
ELF File Creation
The bulk of the linking process occurs during the creation of the .elf file.
The Arduino IDE uses AVR-GCC to combine/link the object files and the
archive file into a single Executable and Linkable Format output - .elf file.
avr-gcc
-Os
-Wl,--gc-sections
mmcu={boardPreferences.get("build.mcu")
}
-o
-L
-lm

EEP File Creation


The .eep file is created by performing an AVR-OBJCOPY using
theafore-mentioned.elf file as input. The Arduino IDE executes the
AVR-OBJCOPY command using the following program options.
avr-objcopy
-O
-R
ihex
-j
.eeprom
--set-section-flags=.eepromalloc,load
--no-change-warnings
--change-section-lma
.eeprom=0

HEX File Creation


The final step the Arduino IDE performs during the build process is
to create the .hex file. This is the file that is passed to AVRDUDE
when uploading code to the Arduino board.
avr-objcopy
-R
ihex
.eeprom

-O

Conclusion
The Arduino Team did an excellent job creating a user friendly
experience. A big part of that is removing theburdenof creating and
maintaining makefiles for your embedded systems work.
The Arduino IDE is well suited for the novice software develop and of
course the hardware platform is a great tool for many fun and
excitinghobbyistendeavors. From a professional perspective the tool
does have its short-comings. Overall I enjoy Arduino, and the team
that developed it.

http://openhardwareplatform.blogspot.com/2011/03/inside-arduino-build-process.html

Arduino Project Ideas


let me GOOGLE that for you...

http://www.instructables.com/id/20-Unbelievable-Arduino-Projects/

http://hacknmod.com/hack/top-40-arduino-projects-of-theweb/
http://www.makeuseof.com/tag/8-cool-components-arduinoprojects/
http://www.chrismarion.net/index.php?
option=com_content&view=article&id=121:firehero&catid=4
3:pyrotechnics&Itemid=226

Arduinos in Space!

http://www.kickstarter.com/projects/575960623/ardusat-your-arduinoexperiment-in-space

Inside ArduSAT

ArduSAT Ideas
SCIENCE: Meteor Hunter - Small meteors that strike the atmosphere every day created
trails of ionized gas in the atmosphere in the upper atmosphere. Write an experiment to try
and detect meteor impacts, by listening for radio stations beyond the horizon, reflected by
the meteor trails!
FINANCE and SECURITY: True Random Number Generator - Cosmic rays are truly
random and can be used to generate a sequence of truly random numbers. These are crucial
(and hence valuable) for devising and testing financial models, secure codes, simulations and
other scientific and commercial applications.
ENGINEERING: Your Eye in the Sky -Try writing an app that would synchronize the output
of a head mounted-gyro to the steering system on the satellite. If youre feeling really
ambitious, try downlinking the attitude vector in real-time to watch the satellite follow your
head - you could even tie-in your head-steering to our program that takes pictures! (Talk to
Joel if youre interested in this experiment!)
ENGINEERING:Point-and-shoot -The following settings can be set on the camera:
"exposure, gamma, gain, white balance, color matrix, windowing". Try designing an algorithm
that fine-tunes the settings to take even better pictures or more artistic pictures!
ENTERTAINMENT: Geiger Counter Bingo - Write an app that transmits a message with a
random number and letter every time a particle hits the satellite with enough energy. Have a
'bingo from space' game between HAM radio amateurs.
ENTERTAINMENT: Photography Competition - See who among your friends can snap the
coolest/most interesting picture from space. The eye of a hurricane, sunrise over the Indian

You might also like