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
PPTX
Arduino board program for Mobile robotss
PPTX
Introduction to Arduino Microcontroller
PDF
PDF
The IoT Academy IoT Training Arduino Part 3 programming
PDF
Programming arduino makeymakey
PDF
Arduino reference
KEY
Hello Arduino.
PDF
Lesson-4-Arduino-Programming-dsBasics.pdf
PDF
Intro to Arduino Programming.pdf
PPTX
3.1 coding (project)
PPTX
Arduino cic3
PPTX
Arduino Functions
PPTX
Arduino course
PDF
arduinocourse-180308074529 (1).pdf
PDF
Introduction to Arduino and Circuits
PDF
Arduino programming
PDF
arduino
PDF
Introduction to Arduino Programming
Arduino Section Programming - from Sparkfun
Arduino for Beginners
Arduino board program for Mobile robotss
Introduction to Arduino Microcontroller
The IoT Academy IoT Training Arduino Part 3 programming
Programming arduino makeymakey
Arduino reference
Hello Arduino.
Lesson-4-Arduino-Programming-dsBasics.pdf
Intro to Arduino Programming.pdf
3.1 coding (project)
Arduino cic3
Arduino Functions
Arduino course
arduinocourse-180308074529 (1).pdf
Introduction to Arduino and Circuits
Arduino programming
arduino
Introduction to Arduino Programming

Recently uploaded (20)

PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Advanced IT Governance
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Electronic commerce courselecture one. Pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
KodekX | Application Modernization Development
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Advanced Soft Computing BINUS July 2025.pdf
PPTX
Cloud computing and distributed systems.
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
20250228 LYD VKU AI Blended-Learning.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
cuic standard and advanced reporting.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Advanced IT Governance
Unlocking AI with Model Context Protocol (MCP)
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Electronic commerce courselecture one. Pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Spectral efficient network and resource selection model in 5G networks
KodekX | Application Modernization Development
Diabetes mellitus diagnosis method based random forest with bat algorithm
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Advanced Soft Computing BINUS July 2025.pdf
Cloud computing and distributed systems.
Review of recent advances in non-invasive hemoglobin estimation
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

Arduino sectionprogramming slides