Presentation is loading. Please wait.

Presentation is loading. Please wait.

Arduino Training For You! Learn Programming at Your Own Pace! Chapter 1 A course developed from the text book: “Introduction to Arduino A Piece of Cake!”

Similar presentations


Presentation on theme: "Arduino Training For You! Learn Programming at Your Own Pace! Chapter 1 A course developed from the text book: “Introduction to Arduino A Piece of Cake!”"— Presentation transcript:

1 Arduino Training For You! Learn Programming at Your Own Pace! Chapter 1 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 RoboticsProfessor@gmail.com www.TeachElectronics.com Copyright 2016, Richard T. Vannoy II

2 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.

3 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: alan@introtoarduino.comalan@introtoarduino.com – Purchase text: www.amazon.comwww.amazon.com – Download the free PDF: www.introtoarduino.comwww.introtoarduino.com

4 Instructor Information This PowerPoint presentation – Instructor: Richard T. Vannoy II, M.S.I.T., B.S.E.E.T. – Email: RoboticsProfessor@gmail.comRoboticsProfessor@gmail.com – Web Site: www.TeachElectronics.comwww.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.

5 Here is our first program. Let’s break it down.

6 “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.”

7 “const”, short for “constant” says: “Do not let anyone change the value I assign here (13).”

8 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.

9 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.

10 …And go write the number 13 into this memory location.

11 This tells Arduino to set Pin 13 to be an “OUTPUT” Pin

12 “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.

13 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.

14 …and leave it off for half a second. Next, let’s turn the LED off…

15 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.

16 So that the programmer can put notes in their programs, two types of comment insertion are supported.

17 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.

18 /* means “Begin Comment. */ Means “End Comment.”

19 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.

20 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.

21 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.

22 /* (Slash-Asterisk) begins the comment. */ (Asterisk-Slash) ends the comment.

23 These Asterisks are just a decoration for looks. They have no meaning or effect in the program.

24 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.”

25 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.

26 Different sections of the sketch often have a description header like this to identify what this section does.

27 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.

28 The End You Can Learn Arduino Programming! Your Instructor is: Richard T. Vannoy II RoboticsProfessor@gmail.com www.TeachElectronics.com


Download ppt "Arduino Training For You! Learn Programming at Your Own Pace! Chapter 1 A course developed from the text book: “Introduction to Arduino A Piece of Cake!”"

Similar presentations


Ads by Google