Tải bản đầy đủ (.pdf) (172 trang)

Arduino for kids young and old

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (12.18 MB, 172 trang )


Copyright


From legal to ISBN

Arduino® for Kids Young and Old ©2014 Daniel W. Milligan
All content is copyright 2014, Daniel Milligan. All rights reserved. No part of this publication
or the files that it is comprised of shall be legally produced, reproduced, or transmitted by any form
or any means without the express permission of the publisher.
Published by Daniel Milligan 2014, all photo's and images are copyright Milligan Photography
unless otherwise noted.
Limit of Liability and Disclaimer of Warranty: The publisher has made every effort in
preparing this book to ensure that the content is accurate however the information provided herein is
provided "as is" and without warranty. Daniel Milligan et al makes no representation or warranties
with respect to the accuracy or completeness of the contents of this book and specifically disclaims
any implied warranties of merchantability or fitness for any particular purpose and shall in no event
be liable for any loss of profit or any other commercial damage, including but not limited to special,
incidental, consequential, or other damages.
Trademarks: This book identifies product names and services known or suspected to be
trademarks, registered trademarks, or service marks of their respective holders. They are used
throughout this book in an editorial fashion only. While great care has been taken to appropriately
identify these items, there is potential that some may have not been identified as such and Daniel
Milligan cannot vouch for the accuracy of this information. Use of a term in this book should not be
regarded as affecting the validity of any trademark, registered trademark, or service mark. Daniel
Milligan is not associated with any product or vendor mentioned in this book other then being the
primary of Milligan Photography.
First edition 2014
ISBN-10: 0985855630
ISBN-13: 978-0-9858556-3-5


Thanks go out to all of my friends and family, and especially my wife Sylvine for all of the
support and love through the years.
The resources linked to at the end of this eBook were valid as of the time of the writing of this
eBook and include links to various tools helpful to those getting started with open source hardware
and hobby programming / engineering.



Introduction


Getting started with Ardunio®

First I am going to make some assumptions both knowingly and unknowingly. I work with a lot
of this technology on a regular basis and may inadvertently leave something out. It's not that I don't
feel it's important or needed but more that I might not think it needs explaining or requires additional
detail. With that, if you should have any questions please do not hesitate to email me at Email Dan .
This book is intended for those wanting to start working with open source hardware and
software in order to build their own creations using tools and components readily available. While I
will point you to specific links to learn more about various software and/or hardware modules, I am
not going to get into too much of programming skills 101 or hardware design 101. My assumption is
that you either have some knowledge in this area or are willing to go and learn it as you go. I will try
to cover everything in enough detail that you won't have to dig too far to get additional information
however it will vary depending on the individual. As the title of the book states, this book is focused
on developing with the Arduino® platform. While a number of the examples and overall concepts
will be applicable to a number of micro-controllers, I will be focusing on the Arduino® family of
modules and specifically those built around the Atmel® AVR family of devices.
The following are some basic terms I will be using that you should be aware of.



An experimental design (software/hardware) used to prove a theory or realize
an idea
An open source hardware/software solution used for prototyping
Arduino®
An add on card i.e. expander board to be used in conjunction with an
Shield
Arduino®. This may also be called a daughter board.
Direct Current which is what most prototyping boards utilize
DC
Alternating Current which is the standard current coming into a house and
AC
delivered to each outlet within the house *
A high level programming language and environment originally designed by
Java™
Sun® Computer and now owned by Oracle®
C
A high level programming language designed at Bell Labs[ 1 ]
An Arduino® term for describing the code to be executed on the Arduino®
Sketch
Universal Serial Bus - standard connection for peripherals such as mice,
USB
keyboards, card readers, etc.
Light Emitting Diode
LED
A software application which generates executable code from a source file
Compiler
such as a sketch.
A data type found in a sketch which can be assigned a value. Variables can
Variable
be of different types to represent different data types such as integers,

characters, and floating point numbers
A value that can represent both positive and negative numbers
Signed value
Unsigned value A value that can only represent positive numbers
A value passed into a method during program execution
Parameter
A value returned by a method once it has finished processing
Return Value
A software construct utilized in high level programming languages such as
Object
Java™ and C++
Baud, Baud Rate The speed at which a communication device operates at
Prototype

* As I am based in the United States, a typical AC current coming into each house would be in
the 120V range while in Europe, the typical value would be in the 240V range. [ 2 ]. While most
items purchased operate via 120V's AC, in actuality they operate on a DC voltage and have
transformers inside or as part of the power cord to convert from AC to DC.
Having the right tool is always beneficial when working on any kind of project. The same is
true when working with both software and hardware. Before you get started you will want to make
sure you have the following items:


a functioning computer (Macintosh® OSX, Windows® based PC, or Linux®)
an available USB host port. The port should be of the type A which will look

something like this:
a clean area to work in and spread out a bit
internet access to look up information
the Java Runtime Environment which can be downloaded: here

the Arduino® development environment which can be downloaded: here
** an Arduino® kit such as this one from MakerSHED
*** a breadboard for prototyping circuits
*** jumper wires for connecting the various parts of your circuits together and
to the Arduino®
A +5v power supply able to deliver 2 Amps of current such as: 5v 2A Supply .
and a comfortable chair
** Electronic components are very susceptible to static electricity. This means that any static
electricity that builds up on yourself could damage the component, like the micro-controller,
when you touch it and transfer that energy from yourself to the component. In some cases, this
damage cannot be detected and the component will work most of the time but not always.
Consider it like a crack in a bowl. It may be fine most of the time however once in a while, some
liquid may spill. And then if it happens to be hot, you will get burned.


*** If you happen to purchase the Arduino® kit as specified above then there will be a
breadboard and jumpers included with it.
The following list are some additional items which are not required however I regularly use
during development.

a soldering iron for building circuits
a solder sucker for removing the excess solder applied with the soldering iron
solid strand wire in the 22 gauge (AWG) area of thickness
wire strippers
wire cutters
small pliers
a multimeter for measuring the voltage at a given point and checking continuity
within a circuit.



Finally a list of some items that you will probably not need however knowing they exist is
always good.

a logic analyzer for debugging protocol issues such as those that might come up
when using serial peripheral interfaces (SPI) among other things
an oscilloscope for debugging issues related to communication signals or Pulse
Width Modulation (PWM) output

Most if these items are available at your local Radio Shack , Fry's , or whichever local


electronics store catering to hobbyists in your corner of the world. In some cases, the devices used
will only be available from on-line merchants which I will attempt to provide various links to
companies I have dealt with successfully.
All circuit diagrams included in this book are provided using the creative commons license for
Attribution - Share Alike 3.0 Unported[ 3 ]. The complete set of circuit diagrams can be found here:
Circuit Diagrams . Each of the circuit diagrams were created using the Fritzing development tool
which can be found on the web at Fritzing.org . For each image that is bound by the creative commons
license, the following icon will be associated with it:
. In addition, I have followed
standard practice in coloring the wires at least in terms of +5v (red) and GND (black). For the
schematics, opposed to using traditional schematics, I have chosen to use the breadboard images out
of Fritzing as I feel they better convey the required information in this context.
With all of that said, lets dive into it and have some fun!


Setup


Getting ready to develop


Setting up your computer for development can be a challenge depending on the tools and the
support available. Hopefully that will not be the case with the Arduino® toolset. However, just in
case, I will walk you through the process. If you are already up and going then please skip over this
chapter and proceed to developing your first sketch in the Arduino® Platform chapter.
While you may already have Java™ installed on your computer, it wouldn't hurt to ensure you
have the latest version so please download the following package from Oracle® here . This page
should detect your current system and give you a download button to start. Once downloaded, follow
the directions provided by Oracle® to install this on your system.
Now that Java™ is ready to go, you can download the Arduino® environment for development.
This software can be found here . For this package, there isn't an installer* per se however you do
need to unzip it. Navigate to your download folder or the destination that you selected when
downloading the package to get access to the application. If you are on a Macintosh OSX® platform
than it will unzip the package for you. If you are on a Windows® platform than the Explorer
application will be able to unzip it for you. For the Linux® platform, when you download it, I expect
it will ask you if it should open it with the archive manager which you can choose to or from the
terminal you can utilize the unzip application. For my own development, I moved the package to my
Development folder which is located on my desktop. I than unzipped it in that location so it will be
centrally located with other things I am working on.
* As of the 1.05 version of the Arduino™ software for Windows® there is an installer
available to assist with installing the Arduino™ software. I have left this chapter in for
reference and for those not on a Windows® based platform.
The following sequence is the platform extraction and placement on my Windows® based
machine and the initial loading of the platform. The first image shows the file once it has been
downloaded from the Arduino™ website.


This image shows the Windows® wizard for extracting a zipped file. I have selected my
Development folder on my desktop for the placement of the platform.


This image shows the Windows® extraction in progress which on my system is fairly slow as it
is not the fastest system in the world.


This image shows the extracted file folder which has inside it the actual Arduino® folder.
Because I didn't want to have to go too deep into the folder hierarchy, I elected to move it up one.


This image shows the extracted folder once I moved it up one level, removing the arduino1.0.3-windows folder.

In this image, I have elected to display everything as large icons. At this point you will be
ready to launch the development platform.

When you first launch the application, you will most likely see the following security warning.
This is expected and is just noting to you, the end user, that the file was downloaded and the publisher
is unknown. While I don't expect you to have any issues running this software, I do advise that you
take the necessary precautions with your system and ensure that you have up to date virus protection
installed and running. Also note the checkbox which will allow you to skip the security warning the
next time you open the application.


At this point, you should see the following main screen for the Arduino® environment.




The Arduino® Platform


What it is


The Arduino® package is a cost effective, easy to use, prototyping board which can be
enhanced to do many tasks. The micro-controller that this board utilizes has been created with a
number of general purpose input and output (GPIO) pins. These GPIO pins have many functions that
you can utilize to create a number of designs. While the controller and overall design are fairly
simple in todays terms, the community that has developed around the platform is where it really
shines. With a simple internet search you can find a number of forums and stores promoting and
selling various products to enhance your Arduino®, from Ethernet port shields to LCD shields to a
number of other's in between.[ 4 ] Considering all of these expansion options are readily available,
the Arduino® becomes a very useful micro-controller. In this book I will focus on the abilities of one
of the Arduino® boards, the Arduino® UNO. It does everything that we need and is based on a 5 volt
system which can be used with a variety of external devices. This will also limit the discussion to
one of the more popular Atmel® AVR micro-controllers, the ATmega328.


What it isn't

This is not a full fledged computer with monitor, keyboard, and mouse as you have probably
already noticed. While it is fast doing simple tasks, it will not break any super computer processing
speeds. With today's processors running at 100x or 200x the speed of this little controller, it isn't
surprising that it isn't as fast as a full fledged computer. The overall Arduino® environment is based
on approachable and easy to use tools. The environment does it's best to prevent mishaps when using
it and the target devices. With this extra security comes limitations and potential speed losses. There
is also potential for conflicting devices due to the overloading of processor pins to internal functions.
However for the kinds of projects that we will want to do, it is more than capable.
Getting Started
So where do we start? Assuming you have already purchased an Arduino® and have the
development environment installed, our first order of business is to make sure everything is working
ok. If you haven't already downloaded and configured your system, take a look at the chapter entitled
Setup for information regarding setting up your development environment. When ready, open up the

development platform and you should see something like this:


Now we need to make sure your Arduino® is properly registered with your development
environment. If you have not connected your Arduino® to your development system than you may
need to load the drivers in order for the board to communicate with your system. On the Windows™
platform, you can find the necessary drivers in the drivers folder under the Arduino® software folder.
If you are running on the Macintosh® or Linux® then you will want to visit the USB chip
manufacturer web page to download the drivers for your particular system. They can be found here .
You will also find the latest Windows® drivers there.
The first thing to notice in the previous image is the currently selected board and


communication port i.e. COM port. This is shown in the lower right hand side of the image. This
development board is an Arduino® UNO connected to COM3. In order to work with your Arduino®
you will need to ensure the correct COM port is selected along with the correct hardware board. To
do this, select the tools menu item on the menu bar.
Note: the menu can take some time to actually pop up depending upon the user's
environment.
From the tools menu, select board and then select the type of board that you have. The
following image shows the board selection where I have selected the Arduino® UNO as my board.


Once the proper board has been selected, the corresponding COM port that the operating
system has assigned to the development board can be selected. The following image shows the
selection of the COM port for the attached Arduino® board.

Before we go any further, it will be good to look at some of the different variable types that you
may find within an Arduino® sketch. The following are some of the more common variable types you
may come across:



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×