SlideShare a Scribd company logo
“resources that can be used, redistributed or rewritten free of charge.
often software or hardware.”
“technology which makes use of the controlled motion of electrons
through different media.”
“an original Form that can serve as a basis or standard for other things.”
“hardware architecture with software framework on which other software
Can run.”
open source‐
electronics‐
Prototype‐
Platform‐
what is an
arduino?
it’s an open‐source
electronics prototyping
platform.
what does that mean?
by Jody Culkin
Microcontrollers use inputs and outputs Like any
computer. Inputs capture information From the user
or the environment while Outputs do something with
the information that has been captured.
a mouse is a common
input device
for a desktop computer,
a monitor is a common
output device.
Or it can respond to something as
simple as the press of a switch.
ON OFF
An Arduino contains a microchip, which is a very small computer that you can program. You can
attach sensors to it that can measure conditions (like how much light there is in the room). It
can control how other objects react to those conditions (room gets dark, led turns on).
microchip
breadboard
led
photocell
Digital information
is discrete and
finite. all
information is
described in two
states, 1 or 0,
on or off.
Analog information
is characterized
by its continuous
nature. it can have an
infinite number
of possible
values.
a switch is a digital input, a sensor is an
analog input. the range of an analog sensor
is limited by its conversion to digital data.
inputs and outputs can be digital or analog.
Digital information is binary‐ it is either true
or false. Analog information is continuous, it
can hold a range of values.
whats the
difference between
digital and analog
inputs and
outputs?
any object we want to turn on and off and
control could be An output. It could be a
motor or even a computer.
DC Motor
A switch or A sensor could be An input
into the Arduino.
momentary switch
force
sensitive
resisitor
the water analogy is commonly used to explain these terms. Here’s one model.
the speed of flow
is determined by voltage
amount of flow moving through
pipes is current
resistance increases or
decreases flow
Resistance (R)
is a material's
opposition to
the flow of
electric
current.
It is measured
in ohms.
Current (I)
is the amount
of flow
through a
conductive
material.
It is measured
in amperes
or Amps.
Voltage (V)
is a measure
of electrical
potential.
It is measured
in volts.
Electricity is the flow of energy through a conductive material.
voltage?
current?
resistance?
Ohm’s law?
Before we plug in the Arduino,
we will review a few terms
and principles that have to
do with how electricity (and
therefore electronics) works.
This is a schematic of the same circuit (it
represents the circuit using symbols for the
electronic components). When the switch is
closed, current flows from the power
source and lights the lamp.
DC power source
Lamp
Switch
+
-
now let’s look at a simple circuit. every
circuit is a closed loop that has an energy
source (battery) and a load (lamp). The load
converts the elecrical energy of the battery
and uses it up. this one has a switch too.
or increase the
potential, more flow.
for example, Increase
the resistance, less
flow.
There is a relationship between voltage,
current and resistance, discovered by Georg
Ohm, a German physicist.
OHM’s law
current = voltage/resistance
(i = v/r)
or
Resistance = voltage/current
(r = v/i)
or
Voltage = Resistance * current
(v = r*i)
you’ll have to download and install software
to program the arduino. it is available from
the URL above Free of charge. the ARduino
software runs on the Mac os X, Windows and
linux Platforms.
http://arduino.cc/en/Main/Software
download here:
Attaching the arduino to a computer with
a usb cable will supply The 5 volts of power
we need and allow us to start programming.
The arduino will need power to run. we will
need to attach it to a computer to program it.
Now that we’ve reviewed some
basics of how electricity
works, Let’s get back t0
the arduino.
I
I
Alternating Current
(AC)
I
I
Direct Current
(DC)
There are two Common types of circuits,
Direct Current and Alternating Current.
In a Dc circuit, the current always flows in
one direction. In AC, the current flows in
opposite directions in regular cycles. We will
only talk about Dc circuits here.
Next select the serial port.
(Tools > serial port) On a mac it will be
something like /dev/tty.usbmodem. On a
windows machine, it will be com3 or something
like that.
Launch the arduino software. in the tools menu,
select the board you are using (tools > board).
for example, Arduino Uno.
When you have installed the software,
Connect the arduino. An led marked ON
should light up on the board.
for instructions on how to install
arduino software on a mac:
http://www.arduino.cc/en/Guide/MacOSX
For Instructions on how to install
on Windows:
http://www.arduino.cc/en/Guide/Windows
For Instructions on how to install
on Linux:
http://www.arduino.cc/playground/Learning/Linux
go to the URLS above for detailed instructions on
installing the software on these platforms.
the led at pin 13 on the arduino starts blinking.
int ledPin = 13;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
Serial.println(analogRead(A0);
}
To upload the sketch to the arduino board,
click the upload button on the strip of
buttons at the top of the window. some
messages will appear in the bottom of the
window, finally Done Uploading.
Upload button
The Arduino IDE allows you to write Sketches, or programs
and upload them to the Arduino board. open the blink example
in the file menu. File > Examples > 1.Basics > Blink.
When you downloaded the
Arduino software, you
downloaded an IDE. it combines
a text editor with a compiler
and other features to help
programmers develop software.
what’s an
Integrated
Development
environment?
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
//DeClares block of code
//declares block of code
//sets pin 13 to output
//sets pin 13 low
//sets pin 13 high
//pause 1 second
//pause 1 second
//End block of code
//End block of code
For now, let’s look at this simple script line
by line & see what each line does.
http://arduino.cc/en/Reference/HomePage
check out the arduino website for the
arduino reference guide and many other
resources to learn the language.
setup: happens one time when
program starts to run
Loop: repeats over and
over again
These Are both blocks of code called
functions that every sketch will have. They
are blocked out by curly Braces { }.
void setup() {
// initialize the digital pin as an output.
// Pin 13 has LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
}
a sketch, like a program written in any
language, is a Set of instructions for the
computer. If we look closely at the Blink
sketch, we see there are 2 major parts,
setup and loop.
When current flows through a led (Light
emitting Diode) in the right direction, it
lights up. we’ll attach an LEd to the
breadboard, then to the arduino so we can
control it with code.
anode
(connects
to power)
cathode
(connects
to ground)
we will connect power and ground from the
arduino board to the vertically connected
strips on the left and right with 22 gauge
wire. other components can be attached to
the holes in the middle and to power and
ground as needed.
This breadboard has 2 rows of holes running
down the left and right side, and 5 rows of
holes on either side of a middle indentation.
the side rows are connected vertically,
each Row of 5 holes in the middle are
connected horizontally.
holes connected
vertically
holes connected
horizontally
How do we control objects that are not on
the arduino board? we will connect the arduino
to a solderless breadboard. This will allow
us to quickly set up and test circuits.
the led blinks on for half a second, then
blinks off for half a second, over and over
again.
click verify on the menu to check your code. if
there aren’t any errors, click upload to put
your program on the arduino.
upload button
verify button
void setup() {
pinMode(2, OUTPUT);
}
void loop() {
digitalWrite(2, HIGH);
delay(500);
digitalWrite(2, LOW);
delay(500);
}
in setup, we set pin 2 to be an
output. in loop, first we set pin 2
high which lights the led. Delay
pauses 500 milliseconds, or half a
second. when pin 2 is set low, the
led goes off, we pause another half
second.
the anode is connected to pin 2 on the arduino through
a 220 ohm resistor. The cathode is connected to
ground. pins 2 through 13 can be configured as digital
inputs or outputs. click New button to start a sketch.
The LED lights when the switch is held down.
void setup() {
pinMode(2, OUTPUT);
pinMode(4, INPUT);
}
void loop() {
if(digitalRead(4)){
digitalWrite(2, HIGH);
}else{
digitalWrite(2, LOW);
}
}
Next we’ll write the code. In setup, we
declare pin 2 an output and pin 4 an input. in
loop, we use an if statement, if we read pin 4
as high, we set the led pin to high, otherwise
we set the led pin to low, turning it off.
Connect one end of a momentary switch to pin 4 on the
Arduino, with a 10k resistor connected to ground
attached to the same end. Attach the other end to
power. We will leave the LED attached to the same pin.
Next we will add a switch, a digital
input, so we can turn the LED off
and on.
Serial Monitor
click to open
serial window
after you have uploaded the script to the
arduino, click the Serial Monitor button in
order to see the values as you turn the pot.
A window will open, and you will see values
ranging from 0 to 1024 as the pot is turned.
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println(analogRead(A0));
}
First we will look at the range of values we
get by turning the pot using the Serial
monitor. in our code, we initialize the serial
object in setup, setting a baud rate of 9600.
In loop, We read the value from analog pin a0
and print it to the serial object using the
printLn function,
Attach the middle pin on the potentiometer to Analog pin
A0. attach one end of the pot to power, the other to
ground.
Now we will set up an analog input.
We’ll use a potentiometer.
a potentiometer, or pot, is a
variable resistor. the amount
of resistance changes as it
is turned, increasing or
decreasing depending on
which direction it is
turned.
The brightness of the LED changes, ranging
from completely off to very bright as you
turn the pot.
int sensorValue = 0;
void setup() {
pinMode(3,OUTPUT);
}
void loop() {
sensorValue = analogRead(A0);
analogWrite(3, sensorValue/4);
}
First we create a variable to store the value
of the pot. In setup we make pin 3 an output.
In loop, we store the value we have read from
pin a0 in our variable. Then we write the value
to pin 3, our led pin. we have to divide the
variable by 4, so we will have a range of values
from 0 to 255, or a byte.
100% Duty Cycle - analogWrite(255)
5V
0V
50% Duty Cycle - analogWrite(127)
5V
0V
0% Duty Cycle - analogWrite(0)
5V
0V
We’ll use pulse width modulation
(PWM). This is a method of simulating
an analog value by manipulating the
voltage, turning it on and off at
different rates, or duty cycles. you
can use pwm with pins 3, 5, 6, 9, 10,
and 11.
Let’s use the changing values we receive from the pot
as a dimmer to control an LED. attach the anode through
a resistor to the board at pin 3, Cathode to ground.
all text and drawings by Jody Culkin
for more, check out jodyculkin.com
Special Thanks to Tom Igoe, Marianne petit, Calvin
Reid, The faculty and staff of the interactive
telecommunications program at nyu, particularly
Dan o’sullivan, Danny rozin and Red burns. thanks
to Cindy karasek, chris Stein, sarah teitler, kathy
goncharov & zannah marsh.
many, many thanks to the Arduino team for bringing
us this robust and flexible open source platform.
and thanks to the lively, active and ever growing
arduino community.
Introduction to Arduino by Jody Culkin
is licensed under a Creative Commons
Attribution‐NonCommercial‐ShareAlike 3.0
Unported License.
books
Tutorials
Arduino site Tutorials
http://www.arduino.cc/en/Tutorial/HomePage
Lady Ada
http://www.ladyada.net/learn/arduino/
Instructables
http://www.instructables.com/tag/type‐id/
category‐technology/channel‐arduino/
Getting Started with Arduino by Massimo Banzi
Making Things Talk: Using Sensors, Networks, and
Arduino to see, hear, and feel your world by
Tom Igoe
Physical Computing: Sensing and Controlling
the Physical World with Computers by Dan
O'Sullivan & Tom Igoe
Arduino Cookbook by Michael Margolis
Links
Supplies
Software
Software Download
http://www.arduino.cc/en/Main/Software
Language Reference
http://arduino.cc/en/Reference/HomePage
Sparkfun Electronics
http://www.sparkfun.com/
Adafruit Industries
http://adafruit.com/
Maker Shed
http://www.makershed.com/
Jameco Electronics
http://www.jameco.com/
That’s it!
This is a very brief
intro. in the next
Panels, there are
links and other
resources. check
them all out,
you’ll find lots
more!

More Related Content

PDF
02 Sensors and Actuators Understand .pdf
PPT
Intro to Arduino
PPTX
Arduino Slides With Neopixels
PPTX
Arduino Workshop Slides
PPTX
Arduino slides
PDF
Getting startedwitharduino ch04
PPTX
Designers, please mind the gap! Let's get started with Arduino
02 Sensors and Actuators Understand .pdf
Intro to Arduino
Arduino Slides With Neopixels
Arduino Workshop Slides
Arduino slides
Getting startedwitharduino ch04
Designers, please mind the gap! Let's get started with Arduino

Similar to Arduino Comic-Jody Culkin-2011 (20)

PPT
13223971.ppt
PPTX
Arduino
PDF
Arduino-workshop.computer engineering.pdf
PDF
arduino
PDF
Arduino spooky projects_class1
DOCX
Arduino PAPER ABOUT INTRODUCTION
PPTX
Arduino Workshop (3).pptx
DOCX
Arduino and Circuits.docx
PPT
arduino
PDF
Ardx experimenters-guide-web
PDF
Arduino experimenters guide ARDX
PDF
Ardx eg-spar-web-rev10
PPTX
Arduino Intro Guide 2
PPTX
Aurdino presentation
PPTX
Arduino
PPTX
Ardui no
PDF
arduinoworkshop-160204051621.pdf
PDF
Arduino experimenters guide hq
PPTX
Introduction To Arduino-converted for s.pptx
PDF
Intro arduino English
13223971.ppt
Arduino
Arduino-workshop.computer engineering.pdf
arduino
Arduino spooky projects_class1
Arduino PAPER ABOUT INTRODUCTION
Arduino Workshop (3).pptx
Arduino and Circuits.docx
arduino
Ardx experimenters-guide-web
Arduino experimenters guide ARDX
Ardx eg-spar-web-rev10
Arduino Intro Guide 2
Aurdino presentation
Arduino
Ardui no
arduinoworkshop-160204051621.pdf
Arduino experimenters guide hq
Introduction To Arduino-converted for s.pptx
Intro arduino English
Ad

More from ΚΔΑΠ Δήμου Θέρμης (16)

PDF
Λογικά Κυκλώματα - Ασκήσεις
PDF
LEGO Mindstorms EV3 Maze Solver TRIK Studio
PDF
LEGO Mindstorms EV3 Control Flow TRIK Studio
PDF
LEGO Mindstorms EV3 Oscillation and Magnet TRIK Studio
PDF
LEGO Mindstorms EV3 Exit Cave TRIK Studio
PDF
LEGO Mindstorms EV3 Gyro Sensor TRIK Studio
PDF
LEGO Mindstorms EV3 Wall Follow TRIK Studio
PDF
LEGO Mindstorms EV3 Variables TRIK Studio
PDF
LEGO Mindstorms EV3 Line Follow Proportional TRIK Studio
PDF
LEGO Mindstorms EV3 Floor Sweep TRIK Studio
PDF
LEGO Mindstorms EV3 Line Follow Zig Zag TRIK Studio
PDF
CoderZ Adventure with LEGO SPIKE Prime - Mission 2
PDF
CoderZ Adventure with LEGO SPIKE Prime
PPTX
Γυροσκόπιο - LEGO Mindstorms EV3 - Εκπαιδευτική Ρομποτική
Λογικά Κυκλώματα - Ασκήσεις
LEGO Mindstorms EV3 Maze Solver TRIK Studio
LEGO Mindstorms EV3 Control Flow TRIK Studio
LEGO Mindstorms EV3 Oscillation and Magnet TRIK Studio
LEGO Mindstorms EV3 Exit Cave TRIK Studio
LEGO Mindstorms EV3 Gyro Sensor TRIK Studio
LEGO Mindstorms EV3 Wall Follow TRIK Studio
LEGO Mindstorms EV3 Variables TRIK Studio
LEGO Mindstorms EV3 Line Follow Proportional TRIK Studio
LEGO Mindstorms EV3 Floor Sweep TRIK Studio
LEGO Mindstorms EV3 Line Follow Zig Zag TRIK Studio
CoderZ Adventure with LEGO SPIKE Prime - Mission 2
CoderZ Adventure with LEGO SPIKE Prime
Γυροσκόπιο - LEGO Mindstorms EV3 - Εκπαιδευτική Ρομποτική
Ad

Recently uploaded (20)

PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Cell Structure & Organelles in detailed.
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Lesson notes of climatology university.
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Classroom Observation Tools for Teachers
PDF
Complications of Minimal Access Surgery at WLH
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Computing-Curriculum for Schools in Ghana
STATICS OF THE RIGID BODIES Hibbelers.pdf
human mycosis Human fungal infections are called human mycosis..pptx
VCE English Exam - Section C Student Revision Booklet
Final Presentation General Medicine 03-08-2024.pptx
Renaissance Architecture: A Journey from Faith to Humanism
Cell Structure & Organelles in detailed.
PPH.pptx obstetrics and gynecology in nursing
Anesthesia in Laparoscopic Surgery in India
2.FourierTransform-ShortQuestionswithAnswers.pdf
Lesson notes of climatology university.
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
GDM (1) (1).pptx small presentation for students
Module 4: Burden of Disease Tutorial Slides S2 2025
102 student loan defaulters named and shamed – Is someone you know on the list?
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Classroom Observation Tools for Teachers
Complications of Minimal Access Surgery at WLH
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Computing-Curriculum for Schools in Ghana

Arduino Comic-Jody Culkin-2011

  • 1. “resources that can be used, redistributed or rewritten free of charge. often software or hardware.” “technology which makes use of the controlled motion of electrons through different media.” “an original Form that can serve as a basis or standard for other things.” “hardware architecture with software framework on which other software Can run.” open source‐ electronics‐ Prototype‐ Platform‐ what is an arduino? it’s an open‐source electronics prototyping platform. what does that mean? by Jody Culkin
  • 2. Microcontrollers use inputs and outputs Like any computer. Inputs capture information From the user or the environment while Outputs do something with the information that has been captured. a mouse is a common input device for a desktop computer, a monitor is a common output device. Or it can respond to something as simple as the press of a switch. ON OFF An Arduino contains a microchip, which is a very small computer that you can program. You can attach sensors to it that can measure conditions (like how much light there is in the room). It can control how other objects react to those conditions (room gets dark, led turns on). microchip breadboard led photocell
  • 3. Digital information is discrete and finite. all information is described in two states, 1 or 0, on or off. Analog information is characterized by its continuous nature. it can have an infinite number of possible values. a switch is a digital input, a sensor is an analog input. the range of an analog sensor is limited by its conversion to digital data. inputs and outputs can be digital or analog. Digital information is binary‐ it is either true or false. Analog information is continuous, it can hold a range of values. whats the difference between digital and analog inputs and outputs? any object we want to turn on and off and control could be An output. It could be a motor or even a computer. DC Motor A switch or A sensor could be An input into the Arduino. momentary switch force sensitive resisitor
  • 4. the water analogy is commonly used to explain these terms. Here’s one model. the speed of flow is determined by voltage amount of flow moving through pipes is current resistance increases or decreases flow Resistance (R) is a material's opposition to the flow of electric current. It is measured in ohms. Current (I) is the amount of flow through a conductive material. It is measured in amperes or Amps. Voltage (V) is a measure of electrical potential. It is measured in volts. Electricity is the flow of energy through a conductive material. voltage? current? resistance? Ohm’s law? Before we plug in the Arduino, we will review a few terms and principles that have to do with how electricity (and therefore electronics) works.
  • 5. This is a schematic of the same circuit (it represents the circuit using symbols for the electronic components). When the switch is closed, current flows from the power source and lights the lamp. DC power source Lamp Switch + - now let’s look at a simple circuit. every circuit is a closed loop that has an energy source (battery) and a load (lamp). The load converts the elecrical energy of the battery and uses it up. this one has a switch too. or increase the potential, more flow. for example, Increase the resistance, less flow. There is a relationship between voltage, current and resistance, discovered by Georg Ohm, a German physicist. OHM’s law current = voltage/resistance (i = v/r) or Resistance = voltage/current (r = v/i) or Voltage = Resistance * current (v = r*i)
  • 6. you’ll have to download and install software to program the arduino. it is available from the URL above Free of charge. the ARduino software runs on the Mac os X, Windows and linux Platforms. http://arduino.cc/en/Main/Software download here: Attaching the arduino to a computer with a usb cable will supply The 5 volts of power we need and allow us to start programming. The arduino will need power to run. we will need to attach it to a computer to program it. Now that we’ve reviewed some basics of how electricity works, Let’s get back t0 the arduino. I I Alternating Current (AC) I I Direct Current (DC) There are two Common types of circuits, Direct Current and Alternating Current. In a Dc circuit, the current always flows in one direction. In AC, the current flows in opposite directions in regular cycles. We will only talk about Dc circuits here.
  • 7. Next select the serial port. (Tools > serial port) On a mac it will be something like /dev/tty.usbmodem. On a windows machine, it will be com3 or something like that. Launch the arduino software. in the tools menu, select the board you are using (tools > board). for example, Arduino Uno. When you have installed the software, Connect the arduino. An led marked ON should light up on the board. for instructions on how to install arduino software on a mac: http://www.arduino.cc/en/Guide/MacOSX For Instructions on how to install on Windows: http://www.arduino.cc/en/Guide/Windows For Instructions on how to install on Linux: http://www.arduino.cc/playground/Learning/Linux go to the URLS above for detailed instructions on installing the software on these platforms.
  • 8. the led at pin 13 on the arduino starts blinking. int ledPin = 13; void setup() { pinMode(ledPin, OUTPUT); } void loop() { Serial.println(analogRead(A0); } To upload the sketch to the arduino board, click the upload button on the strip of buttons at the top of the window. some messages will appear in the bottom of the window, finally Done Uploading. Upload button The Arduino IDE allows you to write Sketches, or programs and upload them to the Arduino board. open the blink example in the file menu. File > Examples > 1.Basics > Blink. When you downloaded the Arduino software, you downloaded an IDE. it combines a text editor with a compiler and other features to help programmers develop software. what’s an Integrated Development environment?
  • 9. void setup() { pinMode(13, OUTPUT); } void loop() { digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); } //DeClares block of code //declares block of code //sets pin 13 to output //sets pin 13 low //sets pin 13 high //pause 1 second //pause 1 second //End block of code //End block of code For now, let’s look at this simple script line by line & see what each line does. http://arduino.cc/en/Reference/HomePage check out the arduino website for the arduino reference guide and many other resources to learn the language. setup: happens one time when program starts to run Loop: repeats over and over again These Are both blocks of code called functions that every sketch will have. They are blocked out by curly Braces { }. void setup() { // initialize the digital pin as an output. // Pin 13 has LED connected on most Arduino boards: pinMode(13, OUTPUT); } void loop() { digitalWrite(13, HIGH); // set the LED on delay(1000); // wait for a second digitalWrite(13, LOW); // set the LED off delay(1000); // wait for a second } a sketch, like a program written in any language, is a Set of instructions for the computer. If we look closely at the Blink sketch, we see there are 2 major parts, setup and loop.
  • 10. When current flows through a led (Light emitting Diode) in the right direction, it lights up. we’ll attach an LEd to the breadboard, then to the arduino so we can control it with code. anode (connects to power) cathode (connects to ground) we will connect power and ground from the arduino board to the vertically connected strips on the left and right with 22 gauge wire. other components can be attached to the holes in the middle and to power and ground as needed. This breadboard has 2 rows of holes running down the left and right side, and 5 rows of holes on either side of a middle indentation. the side rows are connected vertically, each Row of 5 holes in the middle are connected horizontally. holes connected vertically holes connected horizontally How do we control objects that are not on the arduino board? we will connect the arduino to a solderless breadboard. This will allow us to quickly set up and test circuits.
  • 11. the led blinks on for half a second, then blinks off for half a second, over and over again. click verify on the menu to check your code. if there aren’t any errors, click upload to put your program on the arduino. upload button verify button void setup() { pinMode(2, OUTPUT); } void loop() { digitalWrite(2, HIGH); delay(500); digitalWrite(2, LOW); delay(500); } in setup, we set pin 2 to be an output. in loop, first we set pin 2 high which lights the led. Delay pauses 500 milliseconds, or half a second. when pin 2 is set low, the led goes off, we pause another half second. the anode is connected to pin 2 on the arduino through a 220 ohm resistor. The cathode is connected to ground. pins 2 through 13 can be configured as digital inputs or outputs. click New button to start a sketch.
  • 12. The LED lights when the switch is held down. void setup() { pinMode(2, OUTPUT); pinMode(4, INPUT); } void loop() { if(digitalRead(4)){ digitalWrite(2, HIGH); }else{ digitalWrite(2, LOW); } } Next we’ll write the code. In setup, we declare pin 2 an output and pin 4 an input. in loop, we use an if statement, if we read pin 4 as high, we set the led pin to high, otherwise we set the led pin to low, turning it off. Connect one end of a momentary switch to pin 4 on the Arduino, with a 10k resistor connected to ground attached to the same end. Attach the other end to power. We will leave the LED attached to the same pin. Next we will add a switch, a digital input, so we can turn the LED off and on.
  • 13. Serial Monitor click to open serial window after you have uploaded the script to the arduino, click the Serial Monitor button in order to see the values as you turn the pot. A window will open, and you will see values ranging from 0 to 1024 as the pot is turned. void setup() { Serial.begin(9600); } void loop() { Serial.println(analogRead(A0)); } First we will look at the range of values we get by turning the pot using the Serial monitor. in our code, we initialize the serial object in setup, setting a baud rate of 9600. In loop, We read the value from analog pin a0 and print it to the serial object using the printLn function, Attach the middle pin on the potentiometer to Analog pin A0. attach one end of the pot to power, the other to ground. Now we will set up an analog input. We’ll use a potentiometer. a potentiometer, or pot, is a variable resistor. the amount of resistance changes as it is turned, increasing or decreasing depending on which direction it is turned.
  • 14. The brightness of the LED changes, ranging from completely off to very bright as you turn the pot. int sensorValue = 0; void setup() { pinMode(3,OUTPUT); } void loop() { sensorValue = analogRead(A0); analogWrite(3, sensorValue/4); } First we create a variable to store the value of the pot. In setup we make pin 3 an output. In loop, we store the value we have read from pin a0 in our variable. Then we write the value to pin 3, our led pin. we have to divide the variable by 4, so we will have a range of values from 0 to 255, or a byte. 100% Duty Cycle - analogWrite(255) 5V 0V 50% Duty Cycle - analogWrite(127) 5V 0V 0% Duty Cycle - analogWrite(0) 5V 0V We’ll use pulse width modulation (PWM). This is a method of simulating an analog value by manipulating the voltage, turning it on and off at different rates, or duty cycles. you can use pwm with pins 3, 5, 6, 9, 10, and 11. Let’s use the changing values we receive from the pot as a dimmer to control an LED. attach the anode through a resistor to the board at pin 3, Cathode to ground.
  • 15. all text and drawings by Jody Culkin for more, check out jodyculkin.com Special Thanks to Tom Igoe, Marianne petit, Calvin Reid, The faculty and staff of the interactive telecommunications program at nyu, particularly Dan o’sullivan, Danny rozin and Red burns. thanks to Cindy karasek, chris Stein, sarah teitler, kathy goncharov & zannah marsh. many, many thanks to the Arduino team for bringing us this robust and flexible open source platform. and thanks to the lively, active and ever growing arduino community. Introduction to Arduino by Jody Culkin is licensed under a Creative Commons Attribution‐NonCommercial‐ShareAlike 3.0 Unported License. books Tutorials Arduino site Tutorials http://www.arduino.cc/en/Tutorial/HomePage Lady Ada http://www.ladyada.net/learn/arduino/ Instructables http://www.instructables.com/tag/type‐id/ category‐technology/channel‐arduino/ Getting Started with Arduino by Massimo Banzi Making Things Talk: Using Sensors, Networks, and Arduino to see, hear, and feel your world by Tom Igoe Physical Computing: Sensing and Controlling the Physical World with Computers by Dan O'Sullivan & Tom Igoe Arduino Cookbook by Michael Margolis Links Supplies Software Software Download http://www.arduino.cc/en/Main/Software Language Reference http://arduino.cc/en/Reference/HomePage Sparkfun Electronics http://www.sparkfun.com/ Adafruit Industries http://adafruit.com/ Maker Shed http://www.makershed.com/ Jameco Electronics http://www.jameco.com/ That’s it! This is a very brief intro. in the next Panels, there are links and other resources. check them all out, you’ll find lots more!