Você está na página 1de 25

An Arduino is an open-source microcontroller development board.

In plain
English, you can use the Arduino to read sensors and control things like motors
and lights. This allows you to upload programs to this board which can then
interact with things in the real world. With this, you can make devices which
respond and react to the world at large.
For instance, you can read a humidity sensor connected to a potted plant and
turn on an automatic watering system if it gets too dry. Or, you can make a
stand-alone chat server which is plugged into your internet router. Or, you can
have it tweet every time your cat passes through a pet door. Or, you can have it
start a pot of coffee when your alarm goes off in the morning.
Basically, if there is something that is in any way controlled by electricity, the
Arduino can interface with it in some manner. And even if it is not controlled by
electricity, you can probably still use things which are (like motors and
electromagnets), to interface with it.
The possibilities of the Arduino are almost limitless. As such, there is no way
that one single tutorial can cover everything you might ever need to know. That
said, Ive done my best to give a basic overview of the fundamental skills and
Arduino IDE for Hobbyists
codebender.cc
Easy Arduino IDE for hobbyists Program Your
Arduino Online
Kerja Online Dibayar
SAMA5D3 Xplained
Tons of Arduino Shields
(http://cdn.instructables.com/F2K/5L77/H05NHB4C/F2K5L77H05NHB4C.LARGE.jpg)
About This Instructable
Posted:
Apr 19, 2012
License:
329,996 views
1,336 favorites
(/member
/randofo/)
randofo (/member
/randofo/)
Randy Sarafan loves you!
(http://www.randysarafan.com)
Follow
My name is Randy and I make stuff at
Instructables HQ. Im also the author of the
books Simple Bots, and 62 Projects to
Make with a Dead Computer. Since I am
always making new things, subscribing
...read more (/member/randofo/)
6454
Bio:
(/id/Robotic-Camera-Dolly-
System)
(/id/Prank-Box)
(/id/Jar-Lantern)
More by randofo
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
(/)
(/)
Explore (/tag/type-id/) Create (/about/submit.jsp) Contests (/contest/) Community (/community/) You ( )
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
1 of 25 4/21/2014 7:45 PM
knowledge that you need to get your Arduino up and running. If nothing more,
this should function as a springboard into further experimentation and learning.
Step 1: Different types of Arduinos
There are a number of different types of Arduinos to choose from. This is a brief
overview of some of the more common types of Arduino boards you may
encounter. For a full listing of currently support Arduino boards, check out the
Arduino hardware page (http://www.arduino.cc/en/Main/hardware).
Arduino Uno
The most common version of Arduino is the Arduino Uno. This board is what
most people are talking about when they refer to an Arduino. In the next step,
there is a more complete rundown of its features.
Arduino NG, Diecimila, and the Duemilanove (Legacy Versions)
Legacy versions of the Arduino Uno product line consist of the NG, Diecimila,
and the Duemilanove. The important thing to note about legacy boards is that
they lack particular feature of the Arduino Uno. Some key differences:
Related
See More (/tag/type-id/?q=)
(http://cdn.instructables.com/FYS/03SJ/H0OJ1LNG/FYS03SJH0OJ1LNG.LARGE.jpg)
(http://cdn.instructables.com/FXR/57Y8/H05NHB4J/FXR57Y8H05NHB4J.LARGE.jpg)
(http://cdn.instructables.com/F2K/5L77/H05NHB4C/F2K5L77H05NHB4C.LARGE.jpg)
(http://cdn.instructables.com/F9Z/VGSB/H05NSX4M/F9ZVGSBH05NSX4M.LARGE.jpg)
(http://cdn.instructables.com/FG8/RZ2L/H05NSX4N/FG8RZ2LH05NSX4N.LARGE.jpg)
(http://cdn.instructables.com/FDU/OYP5/H05Y7GWQ/FDUOYP5H05Y7GWQ.LARGE.jpg)
intro (/tag/type-id/category-technology/keyword-intro/)
introduction (/tag/type-id/category-technology
/keyword-introduction/)
beginning (/tag/type-id/category-technology/keyword-
beginning/)
beginner (/tag/type-id/category-technology/keyword-
beginner/)
Arduino (/tag/type-id/category-technology/keyword-
arduino/)
atmega328 (/tag/type-id/category-technology
/keyword-atmega328/)
atmega (/tag/type-id/category-technology/keyword-
atmega/)
atmel (/tag/type-id/category-technology/keyword-
atmel/)
micro (/tag/type-id/category-technology/keyword-
micro/)
controller (/tag/type-id/category-technology/keyword-
controller/)
Tags:
Group
Add instructable to:
Bootloading and Mounting
Arduino Atmega328 - I
made it at TechShop
(/id/Bootloading-
and-Mounting-Arduino-
GOduino II = Arduino +
L293D Variable Speed
Motor Controller
(/id/GOduino-II-Arduino-
L293D-Variable-Speed-
How to Burn Arduino
Bootloader w/ Magnolia
board (Cost and Size of
Pack of Gum KickStar
(/id/How-to-Burn-Arduino-
Lap Stopwatch with
ATmega328 Microcontroller
(/id/Lap-Stopwatch-
with-ATmega328-
Microcontroller/)
The Traveling Geocache!
(/id/The-Traveling-
Geocache/)
by Revolt Lab (/member/Revolt
Lab/)
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
2 of 25 4/21/2014 7:45 PM
The Diecimila and NG use an ATMEGA168 chips (as opposed to the more
powerful ATMEGA328),
Both the Diecimila and NG have a jumper next to the USB port and require
manual selection of either USB or battery power.
The Arduino NG requires that you hold the rest button on the board for a few
seconds prior to uploading a program.
Arduino Mega 2560
The Mega is the second most commonly encountered version of the Arduino
family. The Arduino Mega is like the Arduino Unos beefier older brother. It
boasts 256 KB of memory (8 times more than the Uno). It also had 54 input and
output pins, 16 of which are analog pins, and 14 of which can do PWM.
However, all of the added functionality comes at the cost of a slightly larger
circuit board. It may make your project more powerful, but it will also make your
project larger. Check out the official Arduino Mega 2560 page (http://arduino.cc
/en/Main/ArduinoBoardMega2560) for more details.
Arduino Mega ADK
This specialized version of the Arduino is basically an Arduino Mega that has
been specifically designed for interfacing with Android smartphones.
Arduino LilyPad
The LilyPad was designed for wearable and e-textile applications. It is intended
to be sewn to fabric and connected to other sewable components using
conductive thread. This board requires the use of a special FTDI-USB TTL serial
programming cable (http://www.ftdichip.com/Products/Cables
/USBTTLSerial.htm). For more information, the Arduino LilyPad page
(http://arduino.cc/en/Guide/ArduinoLilyPad) is a decent starting point.
Step 2: Arduino Uno Features
Some people think of the entire Arduino board as a microcontroller, but this is
inaccurate. The Arduino board actually is a specially designed circuit board for
programming and prototyping with Atmel microcontrollers.
(http://cdn.instructables.com/FTA/8EB8/H142A66M/FTA8EB8H142A66M.LARGE.jpg)
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
3 of 25 4/21/2014 7:45 PM
The nice thing about the Arduino board is that it is relatively cheap, plugs
straight into a computers USB port, and it is dead-simple to setup and use
(compared to other development boards).
Some of the key features of the Arduino Uno include:
An open source design. The advantage of it being open source is that it has
a large community (http://arduino.cc/forum/) of people using and
troubleshooting it. This makes it easy to find someone to help you debug
your projects.
An easy USB interface . The chip on the board plugs straight into your USB
port and registers on your computer as a virtual serial port. This allows you to
interface with it as through it were a serial device. The benefit of this setup is
that serial communication is an extremely easy (and time-tested) protocol,
and USB makes connecting it to modern computers really convenient.
Very convenient power management and built-in voltage regulation. You can
connect an external power source of up to 12v and it will regulate it to both
5v and 3.3v. It also can be powered directly off of a USB port without any
external power.
An easy-to-find, and dirt cheap, microcontroller "brain." The ATmega328 chip
retails for about $2.88 on Digikey. It has countless number of nice hardware
features like timers, PWM pins, external and internal interrupts, and multiple
sleep modes. Check out the official datasheet (http://www.atmel.com/Images
/8271s.pdf) for more details.
A 16mhz clock. This makes it not the speediest microcontroller around, but
fast enough for most applications.
32 KB of flash memory for storing your code.
13 digital pins and 6 analog pins. These pins allow you to connect external
hardware to your Arduino. These pins are key for extending the computing
capability of the Arduino into the real world. Simply plug your devices and
sensors into the sockets that correspond to each of these pins and you are
good to go.
An ICSP connector for bypassing the USB port and interfacing the Arduino
directly as a serial device. This port is necessary to re-bootload your chip
(http://www.instructables.com/id/Bootload-an-Arduino-with-a-ZIF-Socket/) if it
corrupts and can no longer talk to your computer.
An on-board LED attached to digital pin 13 for fast an easy debugging of
code.
And last, but not least, a button to reset the program on the chip.
For a complete rundown of all the Arduino Uno has to offer, be sure to check out
the official Arduino page (http://arduino.cc/en/Main/ArduinoBoardUno).
Step 3: Arduino IDE
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
4 of 25 4/21/2014 7:45 PM
Before you can start doing anything with the Arduino, you need to download and
install the Arduino IDE (http://www.arduino.cc/en/Main/software) (integrated
development environment). From this point on we will be referring to the Arduino
IDE as the Arduino Programmer.
The Arduino Programmer is based on the Processing IDE
(http://processing.org/) and uses a variation of the C and C++ programming
languages.
You can find the most recent version of the Arduino Programmer on this page
(http://www.arduino.cc/en/Main/software).
Step 4: Plug it in
(http://cdn.instructables.com/FHS/OMOZ/H0A2H36S/FHSOMOZH0A2H36S.LARGE.jpg)
(http://cdn.instructables.com/FUZ/UHSQ/H0A001RZ/FUZUHSQH0A001RZ.LARGE.jpg)
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
5 of 25 4/21/2014 7:45 PM
Connect the Arduino to your computers USB port.
Please note that although the Arduino plugs into your computer, it is not a true
USB device. The board has a special chip that allows it to show up on your
computer as a virtual serial port when it is plugged into a USB port. This is why it
is important to plug the board in. When the board is not plugged in, the virtual
serial port that the Arduino operates upon will not be present (since all of the
information about it lives on the Arduino board).
It is also good to know that every single Arduino has a unique virtual serial port
address. This means that every time you plug in a different Arduino board into
your computer, you will need to reconfigure the serial port that is in use.
The Arduino Uno requires a male USB A to male USB B cable
(http://www.amazon.com/Black-Hi-Speed-Printer-Scanner-Lexmark/dp/tech-
data/B0030FMQ90).
Step 5: Settings
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
6 of 25 4/21/2014 7:45 PM
Before you can start doing anything in the Arduino programmer, you must set
the board-type and serial port.
To set the board, go to the following:
Tools --> Boards
Select the version of board that you are using. Since I have an Arduino Uno
plugged in, I obviously selected "Arduino Uno."
To set the serial port, go to the following:
Tools --> Serial Port
Select the serial port that looks like:
/dev/tty.usbmodem [random numbers]
(http://cdn.instructables.com/FSL/I0F3/H142PA5I/FSLI0F3H142PA5I.LARGE.jpg)
(http://cdn.instructables.com/F6F/MRQJ/H1426LR2/F6FMRQJH1426LR2.LARGE.jpg)
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
7 of 25 4/21/2014 7:45 PM
Step 6: Run a sketch
Arduino programs are called sketches. The Arduino programmer comes with a
ton of example sketches preloaded. This is great because even if you have
never programmed anything in your life, you can load one of these sketches and
get the Arduino to do something.
To get the LED tied to digital pin 13 to blink on and off, lets load the blink
example.
The blink example can be found here:
Files --> Examples --> Basics --> Blink
The blink example basically sets pin D13 as an output and then blinks the test
LED on the Arduino board on and off every second.
Once the blink example is open, it can be installed onto the ATMEGA328 chip
by pressing the upload button, which looks like an arrow pointing to the right.
Notice that the surface mount status LED connected to pin 13 on the Arduino
will start to blink. You can change the rate of the blinking by changing the length
of the delay and pressing the upload button again.
Step 7: Serial monitor
(http://cdn.instructables.com/FJU/YHUA/H0C6MHGC/FJUYHUAH0C6MHGC.LARGE.jpg)
(http://cdn.instructables.com/FS6/I5IK/H0C6MHGG/FS6I5IKH0C6MHGG.LARGE.jpg)
(http://cdn.instructables.com/FB2/DHZX/H0A00DUB/FB2DHZXH0A00DUB.LARGE.jpg)
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
8 of 25 4/21/2014 7:45 PM
The serial monitor allows your computer to connect serially with the Arduino.
This is important because it takes data that your Arduino is receiving from
sensors and other devices and displays it in real-time on your computer. Having
this ability is invaluable to debug your code and understand what number values
the chip is actually receiving.
For instance, connect center sweep (middle pin) of a potentiometer to A0, and
the outer pins, respectively, to 5v and ground. Next upload the sketch shown
below:
File --> Examples --> 1.Basics --> AnalogReadSerial
Click the button to engage the serial monitor which looks like a magnifying
glass. You can now see the numbers being read by the analog pin in the serial
monitor. When you turn the knob the numbers will increase and decrease.
The numbers will be between the range of 0 and 1023. The reason for this is
that the analog pin is converting a voltage between 0 and 5V to a discreet
number.
(http://cdn.instructables.com/F7G/OG5U/H142Z8QK/F7GOG5UH142Z8QK.LARGE.jpg)
(http://cdn.instructables.com/FHM/9QUH/H143LPL3/FHM9QUHH143LPL3.LARGE.jpg)
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
9 of 25 4/21/2014 7:45 PM
Step 8: Digital in
The Arduino has two different types of input pins, those being analog and digital.
To begin with, lets look at the digital input pins.
Digital input pins only have two possible states, which are on or off. These two
on and off states are also referred to as:
HIGH or LOW
1 or 0
5V or 0V.
This input is commonly used to sense the presence of voltage when a switch is
opened or closed.
Digital inputs can also be used as the basis for countless digital communication
protocols. By creating a 5V (HIGH) pulse or 0V (LOW) pulse, you can create a
binary signal, the basis of all computing. This is useful for talking to digital
sensors like a PING ultrasonic sensor, or communicating with other devices.
For a simple example of a digital input in use, connect a switch from digital pin 2
to 5V, a 10K resistor** from digital pin 2 to ground, and run the following code:
File --> Examples --> 2.Digital --> Button
**The 10K resistor is called a pull-down resistor because it connects the digital
pin to ground when the switch is not pressed. When the switch is pressed, the
electrical connections in the switch has less resistance than the resistor, and the
electricity no longer connects to ground. Instead, electricity flows between 5V
and the digital pin. This is because electricity always chooses the path of least
resistance. To learn more about this, visit the Digital Pins (http://arduino.cc
/en/Tutorial/DigitalPins) page.
Step 9: Analog in
(http://cdn.instructables.com/FT9/0P7B/H142P82N/FT90P7BH142P82N.LARGE.jpg)
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
10 of 25 4/21/2014 7:45 PM
Aside from the digital input pins, the Arduino also boasts a number of analog
input pins.
Analog input pins take an analog signal and perform a 10-bit analog-to-digital
(ADC) conversion to turn it into a number between 0 and 1023 (4.9mV steps).
This type of input is good for reading resistive sensors. These are basically
sensors which provide resistance to the circuit. They are also good for reading a
varying voltage signal between 0 and 5V. This is useful when interfacing with
various types of analog circuitry.
If you followed the example in Step 7 for engaging the serial monitor, you have
already tried using an analog input pin.
Step 10: Digital out
(http://cdn.instructables.com/FID/B5US/H1426JJG/FIDB5USH1426JJG.LARGE.jpg)
(http://cdn.instructables.com/FGG/JIJL/H1426JNH/FGGJIJLH1426JNH.LARGE.jpg)
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
11 of 25 4/21/2014 7:45 PM
A digital out pin can be set to be HIGH (5v) or LOW (0v). This allows you to turn
things on and off.
Aside from turning things on and off (and making LEDs blink), this form of output
is convenient for a number of applications.
Most notably, it allows you to communicate digitally. By turning the pin on and off
rapidly, you are creating binary states (0 and 1), which is recognized by
countless other electronic devices as a binary signal. By using this method, you
can communicate using a number of different protocols.
Digital communication is an advanced topic, but to get a general idea of what
can be done, check out the Interfacing With Hardware (http://arduino.cc
/playground/Main/InterfacingWithHardware) page.
If you followed the example in Step 6 for getting an LED to blink, you have
already tried using a digital output pin.
Step 11: Analog out
As mentioned earlier, the Arduino has a number of built in special functions. One
of these special functions is pulse width modulation, which is the way an Arduino
is able to create an analog-like output.
Pulse width modulation - or PWM for short - works by rapidly turning the PWM
pin high (5V) and low (0V) to simulate an analog signal. For instance, if you
were to blink an LED on and off rapidly enough (about five milliseconds each), it
would seem to average the brightness and only appear to be receiving half the
power. Alternately, if it were to blink on for 1 millisecond and then blink off for 9
millisecond, the LED would appear to be 1/10 as bright and only be receiving
1/10 the voltage.
PWM is key for a number of applications including making sound, controlling the
brightness of lights, and controlling the speed of motors.
For a more in-depth explanation, check out secrets of PWM (http://arduino.cc
/en/Tutorial/SecretsOfArduinoPWM) page.
To try out PWM yourself, connect an LED and 220 ohm resistor to digital pin 9,
in series to ground. Run the following example code:
(http://cdn.instructables.com/FC1/HJ0M/H142Z50T/FC1HJ0MH142Z50T.LARGE.jpg)
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
12 of 25 4/21/2014 7:45 PM
File --> Examples --> 3.Analog --> Fading
Step 12: Write your own code
To write your own code, you will need to learn some basic programming
language syntax. In other words, you have to learn how to properly form the
code for the programmer to understand it. You can think of this kind of like
understanding grammar and punctuation. You can write an entire book without
proper grammar and punctuation, but no one will be abler to understand it, even
if it is in English.
Some important things to keep in mind when writing your own code:
An Arduino program is called a sketch.
All code in an Arduino sketch is processed from top to bottom.
Arduino sketches are typically broken into five parts.
The sketch usually starts with a header that explains what the sketch is
doing, and who wrote it.
1.
Next, it usually defines global variables. Often, this is where constant
names are given to the different Arduino pins.
2.
After the initial variables are set, the Arduino begins the setup routine. In
the setup function, we set initial conditions of variables when necessary,
and run any preliminary code that we only want to run once. This is where
serial communication is initiated, which is required for running the serial
monitor.
3.
From the setup function, we go to the loop routine. This is the main routine
of the sketch. This is not only where your main code goes, but it will be
executed over and over, so long as the sketch continues to run.
4.
Below the loop routine, there is often other functions listed. These functions
are user-defined and only activated when called in the setup and loop
routine. When these functions are called, the Arduino processes all of the
code in the function from top to bottom and then goes back to the next line
in the sketch where it left off when the function was called. Functions are
good because they allow you to run standard routines - over and over -
without having to write the same lines of code over and over. You can
simply call upon a function multiple times, and this will free up memory on
the chip because the function routine is only written once. It also makes
code easier to read. To learn how to form your own functions, check out
this page (http://arduino.cc/en/Reference/FunctionDeclaration).
5.
(http://cdn.instructables.com/FW3/MX1A/H142A629/FW3MX1AH142A629.LARGE.jpg)
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
13 of 25 4/21/2014 7:45 PM
All of that said, the only two parts of the sketch which are mandatory are the
Setup and Loop routines.
Code must be written in the Arduino Language (http://arduino.cc
/en/Reference/HomePage), which is roughly based on C.
Almost all statements written in the Arduino language must end with a ;
Conditionals (such as if statements (http://arduino.cc/en/Reference/If) and for
loops (http://arduino.cc/en/Reference/For)) do not need a ;
Conditionals have their own rules and can be found under "Control
Structures (http://arduino.cc/en/Reference/HomePage)" on the Arduino
Language (http://arduino.cc/en/Reference/HomePage) page
Variables are storage compartments for numbers. You can pass values into
and out of variables. Variables must be defined (stated in the code) before
they can be used and need to have a data type associated with it. To learn
some of the basic data types, review the Language Page (http://arduino.cc
/en/Reference/HomePage).
Okay! So let us say we want to write code that reads a photocell connected to
pin A0, and use the reading we get from the photocell to control the brightness
of an LED connected to pin D9.
First, we want to open the BareMinimum sketch, which can be found at:
File --> Examples --> 1.Basic --> BareMinimum
The BareMinimum Sketch should look like this:
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
Next, lets put a header on the code, so other people know about what we are
making, why, and under what terms:
/*
LED Dimmer
by Genius Arduino Programmer
2012
Controls the brightness of an LED on pin D9
based on the reading of a photocell on pin A0
This code is in the Public Domain
*/
void setup() {
// put your setup code here, to run once:
}
Once that is all squared away, let us define the pin names, and establish
variables:
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
14 of 25 4/21/2014 7:45 PM
/*
LED Dimmer
by Genius Arduino Programmer
2012
Controls the brightness of an LED on pin D9
based on the reading of a photocell on pin A0
This code is in the Public Domain
*/
// name analog pin 0 a constant name
const int analogInPin = A0;
// name digital pin 9 a constant name
Now that variables and pin names are set, let us write the actual code:
/*
LED Dimmer
by Genius Arduino Programmer
2012
Controls the brightness of an LED on pin D9
based on the reading of a photocell on pin A0
This code is in the Public Domain
*/
// name analog pin 0 a constant name
const int analogInPin = A0;
// name digital pin 9 a constant name
If we want to see what numbers the analog pin is actually reading from the
photocell, we will need to use the serial monitor. Lets activate the serial port and
output those numbers:
/*
LED Dimmer
by Genius Arduino Programmer
2012
Controls the brightness of an LED on pin D9
based on the reading of a photocell on pin A0
This code is in the Public Domain
*/
// name analog pin 0 a constant name
const int analogInPin = A0;
// name digital pin 9 a constant name
For more information about formulating code, visit the Foundations Page
(http://arduino.cc/en/Tutorial/Foundations). If you need help with the Arduino
Language, then the Language Page (http://arduino.cc/en/Reference/HomePage)
is the place for you.
Also, the Example Sketch Page (http://arduino.cc/hu/Tutorial/HomePage) is a
great place to start messing around with code. Dont be afraid to change things
and experiment.
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
15 of 25 4/21/2014 7:45 PM
Step 13: Shields
Shields are expansion apdapter boards that plug in over top of the Arduino Uno
and gives it special functions.
Since the Arduino is open hardware, anyone who has the inclination is free to
make an Arduino shield for whatever task they wish to accomplish. On account
of this, there are countless number of Arduino shields out in the wild. You can
find an ever-growing list of Arduino shields (http://www.arduino.cc/playground
/Main/SimilarBoards) in the Arduino playground. Keep in mind that there will be
more shield in existence than you will find on listed on that page (as always,
Google is your friend).
To give you a small sense of the capabilities of Arduino shields, check out these
tutorials on how to use three official Arduino shields:
Wireless SD Shield (http://www.instructables.com/id/Arduino-Wireless-
SD-Shield-Tutorial/)
Ethernet Shield (http://www.instructables.com/id/Arduino-Ethernet-Shield-
Tutorial/)
Motor Shield (http://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/)
Step 14: Building an external circuit
(http://cdn.instructables.com/FHL/1GFX/H0A0LBNW/FHL1GFXH0A0LBNW.LARGE.jpg)
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
16 of 25 4/21/2014 7:45 PM
As your projects get more complex, you will want to build your own circuits to
interfacewith the Arduino. While you wont learn electronics overnight, the
internet is an unbelievable resource for electronic knowledge and circuit
diagrams.
To get started with electronics, visit the Basic Electronics
(http://www.instructables.com/id/Basic-Electronics/) Instructable.
Step 15: Going beyond
From here, the only thing left to do is make some projects. There are countless
awesome Arduino resources and tutorials online.
Be sure to check out the Official Arduino Page (http://arduino.cc/) and Forum
(http://forum.arduino.cc/). The information listed here is invaluable and very
(http://cdn.instructables.com/FY7/TGWQ/H0A2836M/FY7TGWQH0A2836M.LARGE.jpg)
(http://cdn.instructables.com/FG8/BV6T/H0A288B0/FG8BV6TH0A288B0.LARGE.jpg)
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
17 of 25 4/21/2014 7:45 PM
We have a be nice comment policy.
Please be positive and constructive.
I Made it! Add Images Post
(/member
/Moose+Dr/)
2 days ago
Reply (C5WUB7QHU69VVZ5)
flag
(/member
/kooljo/)
11 days ago Reply (C8X7X1NHTS5CQH2)
flag
(/member
/agis68/)
19 days ago Reply (C4K5AB4HTHKFQNM)
flag
(/member
/skar0792/)
2 months ago
Reply (CETUW0DHQV6HULA)
flag
complete. This is great resource for debugging projects.
If you need inspiration for some fun beginner projects, check out the 20
Unbelievable Arduino Projects (http://www.instructables.com/id/20-Unbelievable-
Arduino-Projects/) guide.
For a vast listing or Arduino project, the Arduino Channel
(http://www.instructables.com/tag/type-id/category-technology/channel-arduino/)
is a great place to start.
Thats it. Youre on your own.
Good luck and happy hacking!
Moose Dr (/member/Moose+Dr/)
Exactly what I was looking for. Thanks.
kooljo (/member/kooljo/)
my arduino does not seem to be connecting to the program i selected arduino uno
and the program wont let me select a serial port NEED HELP PLEASE!!!
(http://cdn.instructables.com/FR0/MH4H/HTS5CQCS
/FR0MH4HHTS5CQCS.LARGE.jpg)
agis68 (/member/agis68/)
fantastic tutorial, Please keep inform us
skar0792 (/member/skar0792/)
I must say awesome article. The tutorial is fantastic very clear and
understandable. The way you write is awesome. I understand almost everything
what you taught in this tutorial. I must say thanks a lot for sharing your knowledge.
skar0792 (/member/skar0792/)
It must say awesome article. The tutorial is fantastic very clear and
understandable. The way you write is awesome. I understand almost everything
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
18 of 25 4/21/2014 7:45 PM
2 months ago Reply (CDHVJNZHQV6HUHR)
(/member
/skar0792/)
flag
(/member
/laptoprahul/)
2 months ago
Reply (CKN976BHQU4AN1F)
flag
(/member
/vantuegia/)
3 months ago Reply (CB9LV41HQF9GUIA)
flag
(/member
/tin701/)
8 months ago
Reply (C9V9WX6HKM946Y4)
flag
(/member
/profpat/)
8 months ago
Reply (CM8QW2OHKITG56G)
flag
(/member
/Raphango/)
8 months ago Reply (CTCU6F6HK1DFRS7)
flag
(/member
/Toon_ca7/)
9 months ago Reply (C49HFKDHJ5ZL1CD)
flag
(/member
/earslan1/)
10 months ago Reply (CFEDP0RHH2VMAW6)
flag
(/member
/naldobatumbakal/)
1 year ago Reply (CMM3Z2LHEXS4LID)
flag
(/member
/teknohawk/)
1 year ago Reply (CNBRR4THET0RRZP)
what you taught in this
tutorial. I must say thanks
a lot for sharing your
knowledge.
laptoprahul (/member/laptoprahul/)
Very informative thank you :)
vantuegia (/member/vantuegia/)
Excellent, help me a lot, thank you!
tin701 (/member/tin701/)
Very good
profpat (/member/profpat/)
very good instructable!
Raphango (/member/Raphango/)
Wonderfull tutorial! It has enlightened me up pretty much. Im pretty much familiar
to arduino now, and pretty much confident about not blowing up my projects.
Thank you very much!
Toon_ca7 (/member/Toon_ca7/)
Im looking forward to work some animatronics projects using arduino lillypads.
Was guessing if theres a way you can bring me some starying data about
Arduino, just like this youre publishing here, in a pdf format, so I can study it
offline.
earslan1 (/member/earslan1/)
Thank you, this is very good :)
naldobatumbakal (/member/naldobatumbakal/)
Liked Arduino and I would like to study them.
I have a project that needs to contrlol relays to switch on/of 12volts.
Can Arduino capable of doing multi-switching (9 or 12 volts) around 6 to 10
switches?
I dont often open my account, would it be better to give me a reply on my mail?
at ronald_av@yahoo.com....Thank you very much.
teknohawk (/member/teknohawk/)
The Uno R3 is most likely the "best" Arduino to use. It is probably the newest,
cheapest and smartest to use for protoboarding (or what ever you need it to do). It
has a Atmel328 and is quit common, mostly used by beginners to Arduino, all the
way to Advanced electrical hobbyists. But really, most Arduinos can use a sketch
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
19 of 25 4/21/2014 7:45 PM
flag
(/member
/HBang/)
1 year ago Reply (C9FP9DZHAUNNGHU)
flag
(/member
/charmquark/)
1 year ago Reply (CINX482HAWBWK2P)
flag
(/member
/rustygray/)
1 year ago Reply (CENBRSNH8CVDEVV)
flag
(/member
/randofo/)
1 year ago Reply (CXDZPK3H8CVG2BC)
flag
(/member
/rustygray/)
1 year ago Reply (CBORUZ3HA4MB964)
flag
(/member
/Psychic+Master/)
1 year ago
Reply (CPW9ISHHA5M7P2V)
flag
(/member
/elfarandulero/)
1 year ago Reply (C0Z5IUKH7ZPBXO4)
flag
(/member
/randofo/)
1 year ago Reply (C8SONJQH7UQN496)
meant for " only one type of Arduino"
HBang (/member/HBang/)
Im trying to make a robot arm to grab things and place it in different places. Which
Arduino should I buy? As a beginner, I am having some trouble in figuring out
which Arduino to use... Thank you!:)
charmquark (/member/charmquark/)
Excellent guide to get up and going with arduino! Thanks a lot!
rustygray (/member/rustygray/)
I bought a new Uno board, and it plugs in and lights up, but the serial port
command is greyed out.
I did select the Uno as my board. I reset it, I unplugged and replugged.
I still cannot get the serial port to allow me to make a choice.
Suggestions?
randofo (/member/randofo/) (author) rustygray
...exchange it for a new one?
rustygray (/member/rustygray/) randofo
i obtained a 2nd one and same issue. I have windows 7, and downloaded
the latest software. i will check for an update.
Psychic Master (/member/Psychic+Master/) rustygray
you might need to manually update
the drivers, thats what i had to do with
my mega 2560
elfarandulero (/member/elfarandulero/)
First I have to be clear,what is Arduino I see that name all over the Internet?
randofo (/member/randofo/) (author) elfarandulero
From the first paragraph of my
explanation of what an Arduino is:
An Arduino is an open-source
microcontroller development board. In
plain English, you can use the Arduino
to read sensors and control things like
motors and lights. This allows you to
upload programs to this board which
can then interact with things in the real
world. With this, you can make
devices which respond and react to
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
20 of 25 4/21/2014 7:45 PM
flag
(/member
/elfarandulero/)
1 year ago Reply (CF6SDJ8H7URC19Q)
flag
(/member
/elfarandulero/)
1 year ago Reply (C7Z8PGQH7ZPBXO9)
flag
(/member
/randofo/)
1 year ago Reply (CFRKGHYH7UQN49D)
flag
(/member
/jackjackboom/)
1 year ago Reply (C4LQZUGH4AFSGZE)
flag
(/member
/randofo/)
1 year ago
Reply (CX9WBVHH4AGJHIO)
flag
the world at large.
elfarandulero (/member/elfarandulero/) randofo
Since I dont know anything about
microcontroller; I like Electronics I
keep using the regular PCB for my
projects;let the wizard one work with
Arduino; I dont need Arduino at this
point
elfarandulero (/member/elfarandulero/)
Some people think of the entire Arduino board as a microcontroller, but this is
inaccurate. The Arduino board actually is a specially designed circuit board for
programming and prototyping with Atmel microcontroller.. Then why not use a
regular PCB board? I dont know a hell about microcontroller; I dont even know
what is that and what is the use for microcontroller????/
randofo (/member/randofo/) (author) elfarandulero
Because a PCB board is a fiberglass
board with copper on it. It does not do
anything.
A microcontroller is a computer chip,
which is like a mini computer that
controls things.
You attach microcontrollers (and other
components) to PCB boards.
jackjackboom (/member/jackjackboom/)
Hey Randofo!! I had a few questions about beginning in arduino.
-What would be the best starter project for arduino?
-Do you recommend any particular books or ibles on this subject?
-Does a computer have to have USB 2.0 ports to operate an arduino?
(Mine only has USB 1.0 ports.)
if anybody has any other advice, please leave a comment below.
randofo (/member/randofo/) (author) jackjackboom
I think USB 1.0 should be fine.
I recommend this one ;-)
...but you should try searching the site
for some of the Arduino guides and
eBooks. Those are pretty good. Also,
arduino.cc has a ton of useful
information. It just takes a little digging
through.
What do you ultimately want to make
with an Arduino? Once I have a sense
of that, I can probably recommend
some intro projects that might help
you.
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
21 of 25 4/21/2014 7:45 PM
(/member
/jackjackboom/)
1 year ago Reply (CN3JWXOH4AGJLW8)
flag
(/member
/randofo/)
1 year ago Reply (CQML3PBH4AGJN1R)
flag
(/member
/jackjackboom/)
1 year ago
Reply (CVIFAEFH4V015O8)
flag
(/member
/randofo/)
1 year ago
Reply (CA504RTH4ZN4RKQ)
flag
(/member
/jackjackboom/)
1 year ago Reply (CJADPQDH51AS3RB)
flag
(/member
/randofo/)
1 year ago Reply (CCPHRATH4ZN58CO)
flag
jackjackboom (/member/jackjackboom/) randofo
Also, is an led cube a beginner,
intermediate, or advanced
project?
randofo (/member/randofo/) (author) jackjackboom
An led cube is probably a beginner to
intermediate project. I would start
small with a 3 x 3 x 3 LED cube. It
may not seem like much, but that is
27 LEDs to solder together, which will
take a bit of work.
jackjackboom (/member/jackjackboom/) randofo
I have the cube soldered together!!
However I still need the resistors,
transistors, and perfboard. Good luck at
Red Bull Creation!!!
The people who won last year had a
human sized hamster wheel that
printed dot matrix words. People in the
crowd were told to text it and it would
print the texts.
It was awesome! :):):):):)!!
randofo (/member/randofo/) (author) jackjackboom
Good luck with the cube. We did our
best on the challenge. Now it is up to
the internet to vote for us. I guess we
will see how it goes.
jackjackboom (/member/jackjackboom/) randofo
I finished it!! it works really well! Never
fear with the voting. youve got
everybody on Instructables supporting
you guys!!
randofo (/member/randofo/) (author) jackjackboom
Awesome! Nice job on your first
Arduino project. You should share it
with a Photo Instructable.
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
22 of 25 4/21/2014 7:45 PM
(/member
/jackjackboom/)
1 year ago
Reply (CJEIBEWH4ZN59Q6)
flag
(/member
/randofo/)
1 year ago Reply (C266HHMH51ASO91)
flag
(/member
/jackjackboom/)
1 year ago Reply (CBFJAKKH4AFSHCT)
flag
(/member
/Harshaeinstein/)
1 year ago Reply (CSNCHR7H4AFZFQD)
flag
(/member
/randofo/)
1 year ago Reply (COL7UPYH4AGJHIZ)
flag
jackjackboom (/member/jackjackboom/) randofo
I am going to try to rebuild it with a
hackduino so I can keep the Arduino I
have know. I try to post it then. How
would I build an infrared rc system with
Arduino?
I had a n idea for a door that had a key
fob so that I could remotely unlock the
door to my room. Or build a system
that would open up my closet doors
when I pushed a button. : )
randofo (/member/randofo/) (author) jackjackboom
This might get you started with the IR
part of things:
http://www.instructables.com/id/Clone-
a-Remote-with-Arduino/
(http://www.instructables.com
/id/Clone-a-Remote-with-Arduino/)
There are bunch of projects on
Instructables for electronic door locks.
You should search the site for those.
jackjackboom (/member/jackjackboom/) randofo
I want to tart out with something like a
small led cube. I also found a really
interesting arduino starter kit online.
heres a linkhttp://www.amazon.com
/Arduino-Uno-Starter---Solderless-
Breadboard/dp/B0051QHPJM
/ref=sr_1_2?ie=UTF8&
qid=1341878297&sr=8-2&
keywords=arduino
(http://www.amazon.com/Arduino-
Uno-Starter---Solderless-Breadboard
/dp/B0051QHPJM
/ref=sr_1_2?ie=UTF8&
qid=1341878297&sr=8-2&
keywords=arduino)
Harshaeinstein (/member/Harshaeinstein/)
thank you very much....
i am not able to understand why there is a 16Mhz crystal(SPK 16.000) on
arduino(uno) board.
please help me out..
thank you....
randofo (/member/randofo/) (author) Harshaeinstein
It is on there to provide a stable clock
for the microcontroller.
ms10 (/member/ms10/)
awesome instructable thanks it helped me a lot
my arduino works lights up the green light but when i upload code into it at the
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
23 of 25 4/21/2014 7:45 PM
1 year ago Reply (COQMILTH1EN6RVR)
(/member
/ms10/)
flag
(/member
/waterlubber/)
1 year ago Reply (C088SDSH3KOVX46)
flag
We have a be nice comment policy.
Please be positive and constructive.
I Made it! Add Images Post
minute it says
"arvdude :verification error,first
mismatch at byte 0x00000xc
!= 0x62
arvdude : verification error ;
content mismatch"
i new to arduino and i just
bought it 2 days ago
do you have some idea on
whats going on
waterlubber (/member/waterlubber/) ms10
Oh no...sometimes, you just retry. If
that doesnt work, do this:
V
V
V
V
About Us
Who We Are (/about/)
Advertise (/advertise/)
Contact (/about/contact.jsp)
Jobs (/community/Positions-available-at-Instructables/)
Help (/community?categoryGroup=Help)
Find Us
Facebook (http://www.facebook.com/instructables)
Youtube (http://www.youtube.com/user/instructablestv)
Twitter (http://www.twitter.com/instructables)
Pinterest (http://www.pinterest.com/instructables)
Google+ (https://plus.google.com/+instructables)
Tumblr (http://instructables.tumblr.com)
Resources
For Teachers (/teachers/)
Artists in Residence (/group/air/)
Gift Pro Account (/account/give?sourcea=footer)
Forums (/community/)
Answers (/tag/type-question/?sort=RECENT)
Mobile
Download our new apps for iOS,
Android and Windows 8!
Android (https://play.google.com/store
/apps/details?id=com.adsk.instructables)
iOS (https://itunes.apple.com
/app/instructables/id586765571)
Windows
(http://apps.microsoft.com
/windows/en-us/app/7afc8194-
c771-441a-
9590-54250d6a8300)
Terms of Service (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21959721) |
Privacy Statement (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21292079) |
Legal Notices & Trademarks (http://usa.autodesk.com/legal-notices-trademarks/) | Mobile Site (http://m.instructables.com)
(http://usa.autodesk.com/adsk/servlet/pc/index?id=20781545&siteID=123112)
Join!
2014 Autodesk, Inc.
English
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
24 of 25 4/21/2014 7:45 PM
Go Pro Today (/account/gopro?sourcea=footer)
Were Hiring! (/community/Positions-available-at-Instructables/)
Intro to Arduino by randofo (/member/randofo/)
+ Collection I Made it!
Download (/id/Intro-to-Arduino/?download=pdf) 15 Steps
Favorite
(/id/Intro-to-Arduino/)
Intro to Arduino http://www.instructables.com/id/Intro-to-Arduino/
25 of 25 4/21/2014 7:45 PM

Você também pode gostar