0% found this document useful (0 votes)
45 views

Arduino For Beginners, Chapter 1

Uploaded by

Rick S
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Arduino For Beginners, Chapter 1

Uploaded by

Rick S
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Arduino Training For You!

Learn Programming at Your Own Pace!

A course developed from


the text book:
“Introduction to Arduino
A Piece of Cake!”
By Alan G. Smith

Your Instructor is:


Richard T. Vannoy II
[email protected]
Chapter 1
www.TeachElectronics.com
Copyright 2016, Richard T. Vannoy II
Chapter 1: Getting Started

Learning Objectives
• At the completion of this lesson, the student will be
able to:
– State the use of a constant.
– Explain why setup() and loop() are required functions in all
Arduino sketches (programs).
– Explain the use of the Arduino functions/commands:
pinMode( ), digitalWrite( ) and delay( ).
– Demonstrate how to use the two types of comments used
in Arduino programming.
Text/Author Information
• Text Book used in this course:
– Title: Introduction to Arduino: A piece of Cake!
– Author: Alan G. Smith
– ISBN: 1463698348
– ISBN-13: 978-1463698348
– Email: [email protected]
– Purchase text: www.amazon.com
– Download the free PDF: www.introtoarduino.com
Instructor Information
• This PowerPoint presentation
– Instructor: Richard T. Vannoy II, M.S.I.T., B.S.E.E.T.
– Email: [email protected]
– Web Site: www.TeachElectronics.com

Instructor’s Note:

Great PowerPoint presentations are supposed to have few words and


lots of white space. A typical presentation is meant to augment the
presenter’s dialog, not contain all of the presentation material.
I violate this rule here by maximizing the amount of information on each
slide. This allows any student who cannot attend my presentation to
view the slide show, and learn as much as he could with me
presenting.
Here is our first
program.
Let’s break it down.
“int” says: “Set aside a place
in memory for me to store an
integer (no decimals allowed)
with any value from -32,768 to
+32,767.”
“const”, short for
“constant” says: “Do not
let anyone change the value
I assign here (13).”
This is the name I want to assign to
the memory location where I store the
number 13. “PinLED” reminds me that
this is the Arduino Output Pin I use to
connect my LED in this circuit.
And when I read this in a few months,
or some other programmer reads this, we
will know by the “k” in front of the
“PinLed” that this is a constant.
…And go write the number 13
into this memory location.
This tells Arduino to set
Pin 13 to be an “OUTPUT” Pin
“digitalWrite” allows the user to place zero
volts on a pin with the word “LOW”, or 5
Volts on the Pin with the word “HIGH”.
In this program, LOW turns the LED off and
HIGH turns it on.
This line turns the LED connected to Pin 13
on.
The number in parentheses is always in
milliseconds. (Thousandths of seconds)
This says: “Don’t do anything for 500
milliseconds.”
This keeps the LED lit for one-half of a
second.
Next, let’s turn the LED off…

…and leave it off


for half a second.
This sketch
continuously
flashes the
LED on, then
off once
each second
for as long
as the board
is in the
“Run Mode”
and has
power.
So that the programmer can put notes
in their programs, two types of
comment insertion are supported.
Slash-Asterisk (/*) tells the compiler to
ignore everything from that point until
an Asterisk-Slash (*/) is encountered,
either on this line, or any line below.

This makes the /* */ combination a handy


multi-line comment tool.
/* means “Begin Comment.

*/ Means “End Comment.”


The double slash (//) tells the compiler
to ignore everything from the double
slash to the end of the line.

This is used only for one line. A //


comment does not extend to the next line
or other lines below it.
This is the same “Blink” sketch we just
covered, except that the author has added
a number of comments to make it more
readable and understandable for future
readers.
This section is common at the top of most
programs.
Here is where the author identifies
himself and gives the basics so you
understand what this program does.
/* (Slash-Asterisk) begins
the comment.

*/ (Asterisk-Slash) ends
the comment.
These Asterisks are just
a decoration for looks.
They have no meaning or
effect in the program.
These little arrows are not part of
the program. Some text editors use
them when printing to say “I
couldn’t fit all that you wanted on
this line, so I continued this line
one line down.”
The Slash-Asterisk – Asterisk-Slash
combination is usually used for
multi-line comments, but can also be
used on just one line as shown here.
Different sections of the sketch
often have a description header like
this to identify what this section
does.
Each chapter in the text has Exercises at
the end so you can practice the ability
to make changes in the hardware and the
source code.
The End
You Can Learn Arduino Programming!

Your Instructor is:


Richard T. Vannoy II
[email protected]
www.TeachElectronics.com

You might also like