SlideShare a Scribd company logo
Code
http:/ / arduino.cc/ en/ Reference/ HomePage
The Arduino Environment
Board Type
Serial Port / CO Port
M
The Environment
Parts of the Sketch
Comments
• Comments can be anywhere
Comments
• Comments can be anywhere
• Comments created with / / or / * and
*/
Comments
• Comments can be anywhere
• Comments created with / / or / * and
*/
• Comments do not affect code
Comments
• Comments can be anywhere
• Comments created with / / or / * and
*/
• Comments do not affect code
• You may not need comments, but
think about the community!
O
perators
The equals sign
= is used to assign a value
== is used to compare values
O
perators
And & O
r
&& is “and”
|| is “or”
Variables
Basic variable types:
Boolean
Integer
Character
Declaring Variables
Boolean: boolean variableName;
Declaring Variables
Boolean: boolean variableName;
Integer: int variableName;
Declaring Variables
Boolean: boolean variableName;
Integer: int variableName;
Character: char variableName;
Declaring Variables
Boolean: boolean variableName;
Integer: int variableName;
Character: char variableName;
String: stringName [ ];
Assigning Variables
Boolean: variableName = true;
or variableName = false;
Assigning Variables
Boolean: variableName = true;
or variableName = false;
Integer: variableName = 32767;
or variableName = -32768;
Assigning Variables
Boolean: variableName = true;
or variableName = false;
Integer: variableName = 32767;
or variableName = -32768;
Character: variableName = ‘A’;
or stringName = “SparkFun”;
Variable Scope
W
here you declare your variables matters
Setup
void setup ( ) { }

The setup function comes before
the loop function and is necessary
for all Arduino sketches
Setup
void setup ( ) { }

The setup header will never change,
everything else that occurs in setup
happens inside the curly brackets
Setup
void setup ( ) {
pinMode (13, OUTPUT); }

O
utputs are declare in setup, this is done
by using the pinMode function
This particular example declares digital pin # 13 as an output,
remember to use CAPS
Setup
void setup ( ) { Serial.begin;}

Serial communication also begins in setup
This particular example declares Serial communication at a
baud rate of 9600. More on Serial later...
Setup, Internal Pullup Resistors
void setup ( ) {
digitalWrite (12, HIGH); }

You can also create internal pullup resistors in setup, to do so
digitalW the pin HIG
rite
H
This takes the place of the pullup resistors currently on your
circuit 7 buttons
Setup, Interrupts
void setup ( ) {
attachInterrupt (interrupt, function,
mode) }
You can designate an interrupt
function to Arduino pins # 2 and 3
This is a way around the linear
processing of Arduino
Setup, Interrupts
void setup ( ) {
attachInterrupt (interrupt, function,
mode) }
Interrupt: the number of the interrupt, 0 or 1,
corresponding to Arduino pins # 2 and 3
respectively
Function: the function to call when the
interrupt occurs
Mode: defines when the interrupt should be
triggered
Setup, Interrupts
void setup ( ) {
attachInterrupt (interrupt, function,
mode) }
•LOW whenever pin state is low
•CHANGE whenever pin changes value
•RISING whenever pin goes from low to high
•FALLING whenever pin goes from low to high
Don’t forget to CAPITALIZE
If Statements
if ( this is true ) { do this; }
If
if ( this is true ) { do this; }
Conditional
if ( this is true ) { do this; }
Action
if ( this is true ) { do this; }
Else
else { do this; }
Basic Repetition
•loop
•For
•while
Basic Repetition
void loop ( ) { }
Basic Repetition
void loop ( ) { }
Basic Repetition
void loop ( ) { }

The “void” in the header is what
the function will return (or spit out)
when it happens, in this case it
returns nothing so it is void
Basic Repetition
void loop ( ) { }
The “loop” in the header is what the
function is called, sometimes you make
the name up, sometimes (like loop) the
function already has a name
Basic Repetition
void loop ( ) { }
The “( )” in the header is where you
declare any variables that you are
“passing” (or sending) the function, the
loop function is never “passed” any
variables
Basic Repetition
void loop ( ) { }
Basic Repetition
for (int count = 0; count<10; count++)
{
//for action code goes here
//this could be anything
}
Basic Repetition
for (int count = 0; count<10; count++)
{
//for action code goes here
}
Basic Repetition
for (int count = 0; count<10; count++)
{
//for action code goes here
}
Basic Repetition
for (int count = 0; count<10; count++)
{
//for action code goes here
}
Basic Repetition
for (int count = 0; count<10; count++)
{
//for action code goes here
}
Basic Repetition
for (int count = 0; count<10; count++)
{
//for action code goes here
}
Basic Repetition
for (int count = 0; count<10; count++)
{
//for action code goes here
}
Basic Repetition
while ( count<10 )
{
//while action code goes here
}
Basic Repetition
while ( count<10 )
{
//while action code goes here
//should include a way to change count
//variable so the computer is not stuck
//inside the while loop forever
}
Basic Repetition
while ( count<10 )
{
//looks basically like a “for” loop
//except the variable is declared before
//and incremented inside the while
//loop
}
Basic Repetition
Or maybe:
while ( digitalRead(buttonPin)==1 )
{
//instead of changing a variable
//you just read a pin so the computer
//exits when you press a button
//or a sensor is tripped
}
Q
uestions?
www.sparkfun.com
6175 Longbow Drive, Suite 200
Boulder, Colorado 80301

More Related Content

PPT
Arduino section programming slides
PPT
Falcon初印象
PDF
Swift 2
PDF
Cocoa Design Patterns in Swift
PPT
Buffer OverFlow
PDF
Introduction to Functional Programming (w/ JS)
PDF
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1
PPTX
FParsec Hands On - F#unctional Londoners 2014
Arduino section programming slides
Falcon初印象
Swift 2
Cocoa Design Patterns in Swift
Buffer OverFlow
Introduction to Functional Programming (w/ JS)
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1
FParsec Hands On - F#unctional Londoners 2014

What's hot (20)

PDF
The Swift Compiler and Standard Library
PPTX
Computer programming
PPTX
Python Programming Essentials - M5 - Variables
PDF
A few words about OpenSSL
PPTX
Exploit Research and Development Megaprimer: Unicode Based Exploit Development
PDF
Asterisk: PVS-Studio Takes Up Telephony
PPT
C++ programming
DOC
How To Define An Integer Constant In C
PDF
Creation vsm modelos componentes electronicos
PPT
C Tutorials
PPT
CGI With Object Oriented Perl
PPT
C tutorial
PPT
Gift-VT Tools Development Overview
PPTX
Learn c++ (functions) with nauman ur rehman
PDF
PHP7. Game Changer.
ODP
Php opcodes sep2008
PPT
C tutorial
PPT
Verilog Lecture4 2014
The Swift Compiler and Standard Library
Computer programming
Python Programming Essentials - M5 - Variables
A few words about OpenSSL
Exploit Research and Development Megaprimer: Unicode Based Exploit Development
Asterisk: PVS-Studio Takes Up Telephony
C++ programming
How To Define An Integer Constant In C
Creation vsm modelos componentes electronicos
C Tutorials
CGI With Object Oriented Perl
C tutorial
Gift-VT Tools Development Overview
Learn c++ (functions) with nauman ur rehman
PHP7. Game Changer.
Php opcodes sep2008
C tutorial
Verilog Lecture4 2014
Ad

Viewers also liked (20)

DOC
Rajat_Pathak
PPTX
Up and running with Arduino
PPTX
Wireless networks
PPT
3rd Generation Wireless Networks
PPTX
Some inspirational quotes from swami vivekananda
PPTX
DOORDARSHAN RAIPUR PROJECT PRESENTATION/REPORT PPT ppt
PPTX
personality development
PPT
PPTX
4G wireless Network
DOC
Resume - Altaf Amin
PPTX
Satellite communication
PPT
Vivekananda's ideas on education
PDF
Visual Resume Shivam Dhawan
PPTX
MIT App Inventor + Arduino + Bluetooth
PPTX
How to speak english fluently
PPTX
Analysis of 1G, 2G, 3G & 4G
PDF
How To Increase Motivation – Make Your Dreams Come True
PPTX
Wireless communication
PDF
Arduino Lecture 1 - Introducing the Arduino
PPT
Mobile communication intro
Rajat_Pathak
Up and running with Arduino
Wireless networks
3rd Generation Wireless Networks
Some inspirational quotes from swami vivekananda
DOORDARSHAN RAIPUR PROJECT PRESENTATION/REPORT PPT ppt
personality development
4G wireless Network
Resume - Altaf Amin
Satellite communication
Vivekananda's ideas on education
Visual Resume Shivam Dhawan
MIT App Inventor + Arduino + Bluetooth
How to speak english fluently
Analysis of 1G, 2G, 3G & 4G
How To Increase Motivation – Make Your Dreams Come True
Wireless communication
Arduino Lecture 1 - Introducing the Arduino
Mobile communication intro
Ad

Similar to Arduino sectionprogramming slides (20)

PPT
Arduino Section Programming - from Sparkfun
PDF
Arduino for Beginners
PPT
Verilog Lecture2 thhts
PPTX
Arduino cic3
PDF
[Apostila] programação arduíno brian w. evans
PPT
The JavaScript Programming Language
PPT
Javascript by Yahoo
PPT
The Java Script Programming Language
PPT
Javascript
PPT
Les origines de Javascript
PPT
Javascript
PPT
02basics
PPTX
Arduino board program for Mobile robotss
PDF
Quick swift tour
PDF
PDF
The IoT Academy IoT Training Arduino Part 3 programming
PDF
C++ boot camp part 1/2
PDF
C++ Boot Camp Part 1
PPTX
What’s new in .NET
PDF
Arduino coding class
Arduino Section Programming - from Sparkfun
Arduino for Beginners
Verilog Lecture2 thhts
Arduino cic3
[Apostila] programação arduíno brian w. evans
The JavaScript Programming Language
Javascript by Yahoo
The Java Script Programming Language
Javascript
Les origines de Javascript
Javascript
02basics
Arduino board program for Mobile robotss
Quick swift tour
The IoT Academy IoT Training Arduino Part 3 programming
C++ boot camp part 1/2
C++ Boot Camp Part 1
What’s new in .NET
Arduino coding class

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Big Data Technologies - Introduction.pptx
PDF
KodekX | Application Modernization Development
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Cloud computing and distributed systems.
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
Programs and apps: productivity, graphics, security and other tools
“AI and Expert System Decision Support & Business Intelligence Systems”
Big Data Technologies - Introduction.pptx
KodekX | Application Modernization Development
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Cloud computing and distributed systems.
20250228 LYD VKU AI Blended-Learning.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
cuic standard and advanced reporting.pdf
Encapsulation theory and applications.pdf
Unlocking AI with Model Context Protocol (MCP)
Spectral efficient network and resource selection model in 5G networks
Network Security Unit 5.pdf for BCA BBA.
Mobile App Security Testing_ A Comprehensive Guide.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Digital-Transformation-Roadmap-for-Companies.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
MIND Revenue Release Quarter 2 2025 Press Release

Arduino sectionprogramming slides