You are on page 1of 23

What is Arduino?

Arduino is an open-source physical computing platform based on a simple microcontroller board, and a development environment for writing software for the board. The Gizduino board, available at E-gizmo, is based on Arduino Diecimila, a microcontroller based board based on ATMega168. Arduino comes with its own open-source Integrated Development Environment (IDE).

Why Arduino?
Inexpensive Cross-platform Simple, clear programming environment Open-source and extensible software Open-source and extensible hardware

Gizduino Specications
Microcontroller ATmega1681 Operating Voltage 5V Input Voltage (recommended) 7-12 V Input Voltage (limits) 6-20 V Digital I/O Pins 14 (of which 6 provide PWM output) Analog Input Pins 6 DC Current per I/O Pin 40 mA DC Current for 3.3V Pin 50 mA Flash Memory 16 KB (of which 2 KB used by bootloader)

Integrated Development Environment


The Arduino development environment contains a text editor for writing code, a message area, a text console, a toolbar with buttons for common functions, and a series of menus. It connects to the Arduino hardware to upload programs and communicate with them. It can be downloaded at http://arduino.googlecode.com/files/arduino-0018.zip

Integrated Development Environment


Figure: Arduino IDE

Materials Needed
We will now start to use Arduino by downloading a sketch. Make sure you have the following: Gizduino Board USB Cable (A to B)

Materials Needed

Connect Arduino to PC
Connect the Gizduino board to your computer using the USB cable. The green power LED should go on. Make sure that the power pin selector is placed at USB mode as shown in the picture.

Launching Arduino IDE


Double click the Arduino application

Setting up Arduino IDE


Go to Tools -> Board menu and select Arduino Diecimila Select the serial device of the Arduino board from the Tools -> Serial Port menu. To nd out, you can disconnect your Arduino board and re-open the menu; the entry that disappears should be the Arduino board. Reconnect the board and select that serial port.

Uploading Program
Click Verify button to check your code for syntax errors. After compiling, click Upload' button in the environment. If the upload is successful, the message "Done uploading." will appear in the status bar.

A few seconds after the upload finishes, you should see the pin 13 (L) LED on the board start to blink (in orange). If it does, congratulations! You've gotten Arduino up-and-running

Sample Program
/* Blink Turns on an LED on for one second, then off for one second, repeatedly. The circuit: * LED connected from digital pin 13 to ground. * Note: On most Arduino boards, there is already an LED on the board connected to pin 13, so you don't need any extra components for this example. Created 1 June 2005 By David Cuartielles http://arduino.cc/en/Tutorial/Blink based on an orginal by H. Barragan for the Wiring i/o board */ 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 }

Definition
Sketch -It is the unit of code that is uploaded to and run on an Arduino board. Comments -Comments are ignored by the Arduino when it runs the sketch. -It is there for people reading the code: to explain what the program does, how it works, or why it's written the way it is. -For multi-line comment use /* and */. -For single-line comment use //.

Comment Example
Multi-line Comment Example /* Blink Turns on an LED on for one second, then off for one second,repeatedly. */ Single-line Comment Example // LED connected to digital pin 13

Variables
Variable Place for storing a piece of data Variable has a name, a value, and a type. The following example shows how to create a variable whose name is pin, whose value is 13, and whose type is int. Variable Example int pin = 13;

Variable Example
You may now refer to this variable, by its name, at which point its value will be looked up and used. Variable Example In the statement: pinmode(pin, OUTPUT); It would be equivalent to the following statement: pinmode(13, OUTPUT);

More Variable Examples


Arithmetic Expressions int counter; /*variable names should always start with a letter*/ counter = 55; //counter is equal to 55 counter++; //increment counter by 1, counter = 56 counter--; //decrement counter by 1, counter = 55 counter = counter - 25; */decrease counter by 25, counter = 30*/ counter += 25; //increase counter by 25, counter = 55

Boolean Logic
Definitions AND Symbolized by & (&& if conditional) Returns True only if all inputs are True, otherwise False. OR Symbolized by | (|| if conditional) Returns True if one or more inputs are True, otherwise False.

Boolean Logic Example


Boolean Logic 1010 & 1100 1010 | 1100

Functions
Definition Function Also known as procedure or subroutine. A named piece of code that can be used from elsewhere in a sketch.

Function Example
Function Denition Example void setup(){ // initialize the digital pin as an output: pinMode(ledPin, OUTPUT); } The first line provides information about the function, like its name,"setup". The text before and after the name specify its return type and parameters. The code between the { and } is called the body of the function: what the function does. You can call a function that is already been dened (either in your sketch or as part of the Arduino language). An example would be the delay() function.

Special Functions
There are two special functions that are part of every Arduino sketch: setup() and loop(). Definitions setup() A function that is called once, when the sketch starts. Setting pin modes or initializing libraries are placed here. loop() A function that is called over and over and is the heart of most sketches.

You might also like