Arduinoprogrammingr1 150417185248 Conversion Gate02
Arduinoprogrammingr1 150417185248 Conversion Gate02
Arduinoprogrammingr1 150417185248 Conversion Gate02
1
Arduino Langauge
C++ C++ C++
“Arduino”
Libs Libs Libs
C / C++
(Readable Code)
Assembly
(Readable Code)
Machine Language
(Binary Code)
2
Arduino Langauge
C++ C++ C++
“Arduino”
Libs Libs Libs
C / C++
(Readable Code)
Assembly
(Readable Code)
Machine Language
(Binary Code)
3
Hello World (Blink)
4
Hello World (Blink)
Variable
5
Hello World (Blink)
Comments
6
Hello World (Blink)
Comments
Good Comment:
// Blue LED for Activity Indicator
Bad Comment:
// Pin 13
7
Hello World (Blink)
Functions
8
Hello World (Blink)
Functions
9
Hello World (Blink)
Instruction
10
Hello World (Blink)
Instruction
11
Hello World (Blink)
Function Call
12
Hello World (Blink)
Arguments
13
Hello World (Blink)
14
IDE Tools Menu
15
IDE Tools Menu
16
IDE Tools Menu
17
IDE Tools Menu
18
Arduino IDE
Compiler Output
19
Arduino IDE
Serial Monitor
Compiler Output
20
Arduino IDE
Verify & Upload Serial Monitor
Compiler Output
21
Arduino IDE
Verify & Upload Serial Monitor
Compiler Output
Check the correct board and serial port are selected in the tools menu!
23
Hello World
Serial Example
24
Serial objects
25
Serial objects
Enables Serial
Baud
Rate
26
Serial objects
Print
and Println
Variables
Strings
Control Characters
27
Serial objects
Print
and Println
Variables
Strings
Control Characters
• Exercise:
29
Variables
30
How Much Memory is
in your Arduino?
31
Variable Types
Bits Unsigned Range Signed Range
0 to 255
char 8 ‘A’..’b’..’X’
N/A
-2,147,483,648 to
long 32 0 to 4,294,967,295
2,147,483,647
32
Variable Do and Don’t
• DO Use Descriptive Names
• “BlueLED”, “ActivityIndicator”
• “Integer”, “Pin13”
33
Variable Scope
34
Variable Scope
Global
35
Variable Scope
Global
Local to loop()
36
Variable Don’t!
37
Variable Don’t!
38
Variable Don’t!
39
arrays
0 1 2 3 4 5
analogReadings[]
40
arrays
0 1 2 3 4 5
analogReadings[]
Size
Elements
41
arrays
0 1 2 3 4 5
analogReadings[]
42
Pin Functions
43
pinMode()
Analog Digital
(A0..A5) (0..13)
45
Pull-Up Resistor
http://www.baldengineer.com/tutorials/arduino-pull-ups/
46
I/O Exercise
47
analogRead()
Analog Digital
Convert
Signal Value
0v to 5v Values 0 to 1023
5 volts
= 4.887mV per Step
1023 Steps
Arguments
Function Name
Return Type
“Return”
Functions
Returning Nothing
Return Type
56
Function Exercise
57
Control Structures
58
if-statements
59
if-statements
60
if-statements
61
if-statements
62
control operators
== Equal to || OR
63
#1 if-statement mistake
64
#1 if-statement mistake
= != ==
65
for() loop example
66
for() loop
67
for() loop
Control Variable
68
for() loop
Control Variable
Condition
69
for() loop
Increment
Control Variable
Condition
70
Array and For Exercise
71
while() loop
72
while() loop
Condition
73
while() loop
Condition
75
More information?
Visit
baldengineer.com
76