there's aUSB instrumentation for reproval the host pc ANd a DC power jack for connecting anexternal 6-20 V power supply, as an instance a nine V battery, once running a programwhereas no
Trang 3© Copyright 2016 by Andy Hayes - All rights reserved.
This document is directed towards providing precise and reliable data with reference tothe subject and issue lined The publication is oversubscribed with the thought that thepublisher isn't needed to render accounting, formally permissible, or otherwise,qualified services If recommendation is important, legal or skilled, a practicedindividual within the profession ought to be ordered
From a Declaration of Principles that was accepted and approved equally by aCommittee of the America Bar Association and a Committee of Publishers andAssociations
All rights reserved No a part of this publication could also be reproduced, keep in avery retrieval system, or transmitted, in any type or by any suggests that, electronic,mechanical, photocopying, recording or otherwise, unless with written permission fromthe publisher
The information provided is declared to be truthful and consistent, in this any liability,
in terms of basic cognitive process or otherwise, by any usage or false of any policies,processes, or directions contained inside is that the solitary and utter responsibility ofthe recipient reader beneath no circumstances can any burden or blame be controlagainst the publisher for any reparation, damages, or financial loss thanks to theknowledge herein, either directly or indirectly
The authors of this book own all copyrights not control by the publisher
The information herein is obtainable for informational functions exclusively, and isuniversal as thus The presentation of the knowledge is while not contract or any form ofguarantee assurance
The trademarks that square measure used square measure with no consent, and also thepublication of the trademark is while not permission or backing by the trademark owner.All and brands and types among this book square measure for elucidative functionssolely and also the in hand by the owners themselves, not related to with this document
Limit of/ disclaimer of warrant: The author and therefore the publisher of this book andconcomitant materials have used their best effort in making ready this program Theauthor and publisher create no illustration or warranties with relevancy the accuracy,application, fitness, or completeness of the content of this program They disclaim anywarranties (expressed or implied), state, or fitness for any specific purpose The authorsand publisher shall in no event be control to blame for any loss or alternative damages,
as well as however not restricted to special, tax, accounting or alternative skilled ought
to be sought-after
Trang 4The Arduino project was started in European nation to develop low price hardware forinteraction style an summary is on the Wikipedia entry for Arduino The Arduino homepage is http://www.arduino.cc/.
The Arduino hardware comes in many flavors within the us, Sparkfun(www.sparkfun.com) may be a sensible supply for Arduino hardware
This guide covers the Arduino Uno board (Sparkfun DEV-09950, $29.95), a decentalternative for college kids and educators With the Arduino board, you'll be able towrite programs and make interface circuits to browse switches and different sensors,and to regulate motors and lights with little effort several of the photographs anddrawings during this guide were taken from the documentation on the Arduino website,the place to show if you would like additional info The Arduino section on theAmerican state 2011 computing machine, https://sites.google.com/a/umn.edu/me2011/,covers additional on interfacing the Arduino to the world
This is what the Arduino board sound like.
The Duemilanove board options AN Atmel ATmega328 microcontroller operative atfive V with a pair of computer memory unit of RAM, thirty two computer memory unit ofnonvolatile storage for storing programs and one computer memory unit of EEPROM forstoring parameters The clock speed is sixteen megacycle per second, that interprets toconcerning corporal punishment concerning three hundred,000 lines of C ASCII text fileper second The board has fourteen digital I/O pins and six analog input pins there's aUSB instrumentation for reproval the host pc ANd a DC power jack for connecting anexternal 6-20 V power supply, as an instance a nine V battery, once running a programwhereas not connected to the host pc Headers square measure provided for interfacing
to the I/O pins mistreatment twenty two g solid wire or header connectors for added
www.TechnicalBooksPDF.com
Trang 5data on the hardware, see http://arduino.cc/en/Main/ArduinoBoardUno.
The Arduino programing language could be a simplified version of C/C++ If yourecognize C, programming the Arduino are going to be acquainted If you are doing notgrasp C, no ought to worry as solely a couple of commands square measure required toperform helpful functions
An important feature of the Arduino is that you just will produce an impact program onthe host laptop, transfer it to the Arduino and it'll run mechanically take away the USBcable affiliation to the laptop, and therefore the program can still run from the highest onevery occasion you push the push button take away the battery and place the Arduinoboard in a very closet for 6 months once you reconnect the battery, the last program youkeep can run this implies that you just connect the board to the host laptop to developand correct your program, however once that's done, you not want the laptop to run theprogram
What you would like for a operating System
1 Arduino Duemilanove board
2 USB programming cable (A to B)
3 9V battery or external power offer (for complete operation)
4 Solderless bread board for external circuits, and twenty two g solid wire forconnections
5 Host laptop running the Arduino development atmosphere Versions exist forWindows, Mac and Linux
Trang 6Chapter 1
Installing the Software
Follow the directions on the obtaining Started section of the Arduino computingmachine, http://arduino.cc/en/Guide/HomePage Go all the approach through the steps towherever you see the pin thirteen semiconductor diode blinking this is often theindication that you just have all code and drivers with success put in and may beginexploring together with your own programs
Click for more information on how to connect battery
http://playground.arduino.cc/Learning/9VBatteryAdapter
Caution:
concentrate on the polarity as you connect your battery to the snap as reverse
data might blow out your board.
Disconnect your Arduino from the pc Connect a 9V battery to the Arduino
power jack create used of the battery snap adapter confirm that the blinking
program runs This indicate that you simply will power the Arduino from
electric battery which the program you transfer runs while not having a
affiliation to the host computer
Continue
Make sure your Arduino is connected to the pc with the USB cable You don’t
would like the battery for currently The inexperienced POWER LED can show
lightweight If there was already a program burned into the Arduino, it wil
definetlyl run.
www.TechnicalBooksPDF.com
Trang 7don't place your board on a conductive surface; you may short out the pins at
the back!
Beginn the Arduino development environment In Arduino-speak, programs known as
“sketches”, but here we call them programs
In the editing window that comes up, input the following program, pay more
attention to where semi-colons show at the end of command lines
void setup(){
Serial.begin(9600); Serial.println("Hello World");}
void loop()
{}
Your window will show something like this
Click the Ctrl-U or transfer button to computing the program and run on the Arduinoboard
Click on the Serial Monitor button If everything is ideal, the monitor window can showyour message and appearance like this
Congratulations; you've got created and run your initial a part of Arduino program!
Push the Arduino push a number of minute and see what's going to happens
Trang 8Click for more https://www.arduino.cc/en/guide/troubleshooting
• Rerun the Arduino program
• Check that the USB cable is connected properly
• Restart your computer as a result of generally the port will lock up
• If the port is already in use, error show up once more once uploading
• Ask a some other person for facilitate
Solderless Breadboards
A solderless bread board is a necessary tool for speedily prototyping electroniccircuits parts and wire push into bread board holes Rows and columns of holes squaremeasure internally connected to create connections simple Wires run from the breadboard to the I/O pins on the Arduino board build connections mistreatment short lengths
of twenty-two g solid wire stripped of insulation regarding 0.25” at every finish Herecould be a photograph of a bread board showing that runs square measure connectedinternally The pairs of horizontal runs at the highest and bottom square measure helpfulfor running power and ground Convention is to create the red coloured run +5 V andalso the blue coloured run Gnd the facility runs square measure typically referred to as
Trang 9Trim wires and part leads so wires and parts lie near to the board
To keep the Arduino board and board along, you'll be able to secure each to a chunk offom-core, cardboard or wood victimisation double-stick foam tape or different suggeststhat
Making use of 22g or 24g wire, connecting the 5V
power pin on the Arduino to the lowest red power bus
on the bread board as well as the Gnd pin on the
Arduino to the lowest blue power buss on the bread
board Connect the notched or flat facet of the crystal
rectifier (the notch or flat is on the rim that rounding
error up the crystal rectifier base; be a lot of attentive
as a result of it onerous someday to locate) to the Gnd
bus and therefore the alternative facet to a free hole in
main area of the bread board Place the electrical
device in order that one finish is within the same
column because the crystal rectifier and therefore the
alternative finish is during a free column From that
column, connect a wire to digital pin two on the
Arduino board Your setup can dispaly like this
Trang 11To know if the crystal rectifier works, take
away the wire from pin two on the Arduino
board and build contact to the 5V power bus
The crystal rectifier ought to come back up
with lightweight If not, attempt dynamical the
procedure
of the LED come back thewire back to were it
had been connected
before in pin two
On the LED, current runs from the anode (+) to
the
cathode (-) that is indicate by the notch The
circuit you only wired up is painted in
schematic type within the figure to the correct
Create and run this Arduino package
Does the LED light up for a second? Press the Arduino reset button to rerun the program
Try this program now, which will flash the LED at 1.0 Hz Everything after the // on aline there is a comment, as is the text between „/*‟ and „*/‟ at the top It is always good
to adding comments to a program
Trang 12void loop() // loop forever
{
digitalWrite(2,HIGH); // pin 2 high (LED on)
delay(500); // wait 500 ms digitalWrite(2,LOW);
// pin 2 low (LED off) delay(500); // wait 500 ms
This exercise indicate however the Arduino will management outside world With
correct interface electronic equipment an equivalent code will turn on and off motors,relays, solenoids, electromagnets, gas valves or the other on-off kind device
www.TechnicalBooksPDF.com
Trang 13Chapter 2
Study a switch
The LED exercise indicate however the Arduino
will management the surface world several
applications need reading the state of sensors,
as well as switches The figure to the proper
shows an image of a pushbutton switch and its
schematic image Note that the image represents a
switch whose contacts square measure ordinarily
open, on the other hand square measure
shorted once the button is pushed If you've got a switch,
use the continuity (beeper) perform of a digital
multi- meter (DMM) to know once the leads
square measure open and once they square
measure connected because the button is pushed
On this exercise, the Arduino can browse the state of a normally-open button switchand show the results on the laptop exploitation the serial.println() command you maywant a switch, a ten kohm electrical device and a few items of 22g hookup wire Ifyou probably did not have a switch, substitute 2 wires and manually connect their freeends to simulate a switch closure The figure below indicate the schematic for thecircuit on the left and a realization on the correct
Trang 14+5 V
10K PIN 3
Gnd
Create and run Arduino program
Open the Serial Monitor window If the switch is open, you'll see a train of 1's on thescreen once closed, the 1's modification to 0's On the hardware facet, once the switch
is open, no current flows through the electrical device once no current flows through aelectrical device, the voltage won't drop across the electrical device, which suggests thevoltage on both sides is that the same In your circuit, once the switch is open, pin three
is at five volts that the pc reads as a one state once the switch is closed, pin three isconnected on to ground, that is at zero volts the pc reads this as a zero state
Watch the activity in the Serial Monitor window as you press and release the switch
Controlling a Small DC Motor
www.TechnicalBooksPDF.com
Trang 15The Arduino will management alittle DC motor through a electronic transistor switch.you may would like a TIP120 electronic transistor, a 1K resistance a 9V battery withbattery snap and a motor.
The TIP120 pins look like this and on a schematic the pins are likethis
Here is the schematic diagram for how to connect the motor
And here may be a pictorial diagram for a way to attach the parts The connections issoldered or they will be created through a solderless bread board
Pin 2
Gnd
Trang 16Pin a pair of may be any digital I/O pin on your Arduino Connect the minus of thebattery to the electrode of the junction {transistor|electronic transistor|semiconductordevice|semiconductor unit|semiconductor} (E pin) and additionally connect the
electrode of the transistor to Gnd on the Arduino board
To check if things ar operating, take a jumper wire and short the collector to the
electrode pins of the semiconductor device The motor ought to activate Next,
disconnect the 1K electrical device from pin a pair of and jumper it to +5V The motorought to activate place the electrical device back to pin a pair of and run the
subsequent check program:
Click on this link for code on the switch
https://www.arduino.cc/en/tutorial/switch
www.TechnicalBooksPDF.com
Trang 17Chapter 3
Arduino Hardware
The power of the Arduino isn't its ability to crunch code, however rather its ability tomove with the skin world through its input-output (I/O) pins The Arduino has fourteendigital I/O pins tagged zero to thirteen that may be wont to flip motors and lights onand off and browse the state of switches
Each digital pin will sink or supply regarding forty mA of current this is often overadequate for interfacing to most devices, however will mean that interface circuitssquare measure required to regulate devices nonetheless straightforward LED's Indifferent words, you can't run a motor directly exploitation the present out there from
AN Arduino pin, however rather should have the pin drive AN interface circuit thatsuccessively drives the motor A later section of this document shows a way to
interface to alittle motor
To move with the skin world, the program sets digital pins to a high or low worthexploitation C code directions, that corresponds to +5 V or zero V at the pin The pin
is connected to external interface natural philosophy and so to the device being
switched on and off The sequence of events is shown during this figure
Program sets pin high/low (1/0)
Board pin set to +5V/0V