Intro to arduino.ppt

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).

description

arduino powerpoint presentation

Transcript of Intro to arduino.ppt

Page 1: Intro to arduino.ppt

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).

Page 2: Intro to arduino.ppt

Why Arduino?

• Inexpensive• Cross-platform• Simple, clear programming environment• Open-source and extensible software• Open-source and extensible hardware

Page 3: Intro to arduino.ppt

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)

Page 4: Intro to arduino.ppt

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

Page 5: Intro to arduino.ppt

Integrated Development Environment

Figure: Arduino IDE

Page 6: Intro to arduino.ppt

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)

Page 7: Intro to arduino.ppt

Materials Needed

Page 8: Intro to arduino.ppt

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.

Page 9: Intro to arduino.ppt

Launching Arduino IDE

• Double click the Arduino application

Page 10: Intro to arduino.ppt

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.

Page 11: Intro to arduino.ppt

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

Page 12: Intro to arduino.ppt

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 2005By 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 offdelay(1000); // wait for a second}

Page 13: Intro to arduino.ppt

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 //.

Page 14: Intro to arduino.ppt

Comment Example

• Multi-line Comment Example/*BlinkTurns on an LED on for one second, then off for

one second,repeatedly.*/• Single-line Comment Example// LED connected to digital pin 13

Page 15: Intro to arduino.ppt

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 Exampleint pin = 13;

Page 16: Intro to arduino.ppt

Variable Example

• You may now refer to this variable, by its name, at which point its value will be looked up and used.

• Variable ExampleIn the statement:

pinmode(pin, OUTPUT);It would be equivalent to the following

statement:pinmode(13, OUTPUT);

Page 17: Intro to arduino.ppt

More Variable Examples

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

Page 18: Intro to arduino.ppt

Boolean Logic

• DefinitionsAND

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.

Page 19: Intro to arduino.ppt

Boolean Logic Example

• Boolean Logic1010 & 11001010 | 1100

Page 20: Intro to arduino.ppt

Functions

• DefinitionFunction

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

Page 21: Intro to arduino.ppt

Function Example• Function Denition Examplevoid 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.

Page 22: Intro to arduino.ppt

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.

Page 23: Intro to arduino.ppt