SlideShare a Scribd company logo
Code 
http:/ / arduino.cc/ en/Reference/HomePage
The Arduino Environment
Board Type
Serial Port / COM Port
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!
Operators 
The equals sign 
= is used to assign a value 
== is used to compare values
Operators 
And & Or 
&& 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 
Where 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); } 
Outputs 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 
digitalWrite the pin HIGH 
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 
}
Questions?
www.sparkfun.com 
6175 Longbow Drive, Suite 200 
Boulder, Colorado 80301

More Related Content

What's hot (20)

Arduino reference
Arduino referenceArduino reference
Arduino reference
Marcos Henrique
 
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1
PVS-Studio
 
RubyConf Portugal 2014 - Why ruby must go!
RubyConf Portugal 2014 - Why ruby must go!RubyConf Portugal 2014 - Why ruby must go!
RubyConf Portugal 2014 - Why ruby must go!
Gautam Rege
 
Bit manipulation in atmel studio for AVR
Bit manipulation in atmel studio for AVRBit manipulation in atmel studio for AVR
Bit manipulation in atmel studio for AVR
Pham Hoang
 
Oop object oriented programing topics
Oop object oriented programing topicsOop object oriented programing topics
Oop object oriented programing topics
(•̮̮̃•̃) Prince Do Not Work
 
Bash Programming
Bash ProgrammingBash Programming
Bash Programming
Andrew Vandever
 
The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212
Mahmoud Samir Fayed
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overview
stn_tkiller
 
The Ring programming language version 1.5.1 book - Part 78 of 180
The Ring programming language version 1.5.1 book - Part 78 of 180The Ring programming language version 1.5.1 book - Part 78 of 180
The Ring programming language version 1.5.1 book - Part 78 of 180
Mahmoud Samir Fayed
 
Programming basics
Programming basicsProgramming basics
Programming basics
246paa
 
C++ Preprocessor Directives
C++ Preprocessor DirectivesC++ Preprocessor Directives
C++ Preprocessor Directives
Wasif Altaf
 
verilog code
verilog codeverilog code
verilog code
Mantra VLSI
 
The Ring programming language version 1.2 book - Part 59 of 84
The Ring programming language version 1.2 book - Part 59 of 84The Ring programming language version 1.2 book - Part 59 of 84
The Ring programming language version 1.2 book - Part 59 of 84
Mahmoud Samir Fayed
 
Creation vsm modelos componentes electronicos
Creation vsm   modelos componentes electronicosCreation vsm   modelos componentes electronicos
Creation vsm modelos componentes electronicos
jeblanco81
 
Php opcodes sep2008
Php opcodes sep2008Php opcodes sep2008
Php opcodes sep2008
bengiuliano
 
Zeppelin Helium: Spell
Zeppelin Helium: SpellZeppelin Helium: Spell
Zeppelin Helium: Spell
PArk Hoon
 
clap: Command line argument parser for Pharo
clap: Command line argument parser for Pharoclap: Command line argument parser for Pharo
clap: Command line argument parser for Pharo
ESUG
 
Verilog Tasks & Functions
Verilog Tasks & FunctionsVerilog Tasks & Functions
Verilog Tasks & Functions
anand hd
 
Specs Presentation
Specs PresentationSpecs Presentation
Specs Presentation
Synesso
 
Inline Functions and Default arguments
Inline Functions and Default argumentsInline Functions and Default arguments
Inline Functions and Default arguments
Nikhil Pandit
 
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 1
PVS-Studio
 
RubyConf Portugal 2014 - Why ruby must go!
RubyConf Portugal 2014 - Why ruby must go!RubyConf Portugal 2014 - Why ruby must go!
RubyConf Portugal 2014 - Why ruby must go!
Gautam Rege
 
Bit manipulation in atmel studio for AVR
Bit manipulation in atmel studio for AVRBit manipulation in atmel studio for AVR
Bit manipulation in atmel studio for AVR
Pham Hoang
 
The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212
Mahmoud Samir Fayed
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overview
stn_tkiller
 
The Ring programming language version 1.5.1 book - Part 78 of 180
The Ring programming language version 1.5.1 book - Part 78 of 180The Ring programming language version 1.5.1 book - Part 78 of 180
The Ring programming language version 1.5.1 book - Part 78 of 180
Mahmoud Samir Fayed
 
Programming basics
Programming basicsProgramming basics
Programming basics
246paa
 
C++ Preprocessor Directives
C++ Preprocessor DirectivesC++ Preprocessor Directives
C++ Preprocessor Directives
Wasif Altaf
 
The Ring programming language version 1.2 book - Part 59 of 84
The Ring programming language version 1.2 book - Part 59 of 84The Ring programming language version 1.2 book - Part 59 of 84
The Ring programming language version 1.2 book - Part 59 of 84
Mahmoud Samir Fayed
 
Creation vsm modelos componentes electronicos
Creation vsm   modelos componentes electronicosCreation vsm   modelos componentes electronicos
Creation vsm modelos componentes electronicos
jeblanco81
 
Php opcodes sep2008
Php opcodes sep2008Php opcodes sep2008
Php opcodes sep2008
bengiuliano
 
Zeppelin Helium: Spell
Zeppelin Helium: SpellZeppelin Helium: Spell
Zeppelin Helium: Spell
PArk Hoon
 
clap: Command line argument parser for Pharo
clap: Command line argument parser for Pharoclap: Command line argument parser for Pharo
clap: Command line argument parser for Pharo
ESUG
 
Verilog Tasks & Functions
Verilog Tasks & FunctionsVerilog Tasks & Functions
Verilog Tasks & Functions
anand hd
 
Specs Presentation
Specs PresentationSpecs Presentation
Specs Presentation
Synesso
 
Inline Functions and Default arguments
Inline Functions and Default argumentsInline Functions and Default arguments
Inline Functions and Default arguments
Nikhil Pandit
 

Viewers also liked (17)

Social media toliver
Social media toliverSocial media toliver
Social media toliver
ryantoliver23
 
Questionnaire radio trailer
Questionnaire radio trailer Questionnaire radio trailer
Questionnaire radio trailer
a2medgroup2
 
Focus group documenatry
Focus group documenatry Focus group documenatry
Focus group documenatry
a2medgroup2
 
ذم الأشاعرة والمتكلمين والفلاسفة لأحمد بن الصديق الغماري
ذم الأشاعرة والمتكلمين والفلاسفة لأحمد بن الصديق الغماريذم الأشاعرة والمتكلمين والفلاسفة لأحمد بن الصديق الغماري
ذم الأشاعرة والمتكلمين والفلاسفة لأحمد بن الصديق الغماري
Om Muktar
 
Highlights of south india
Highlights of south indiaHighlights of south india
Highlights of south india
Kata Travels
 
Potential interview
Potential interviewPotential interview
Potential interview
a2medgroup2
 
คำวินิจฉัย (ฟัตวา) จุฬาราชมนตรี : การชำระล้างหรือทำความสะอาดวัตถุดิบ อุปกรณ์ผ...
คำวินิจฉัย (ฟัตวา) จุฬาราชมนตรี : การชำระล้างหรือทำความสะอาดวัตถุดิบ อุปกรณ์ผ...คำวินิจฉัย (ฟัตวา) จุฬาราชมนตรี : การชำระล้างหรือทำความสะอาดวัตถุดิบ อุปกรณ์ผ...
คำวินิจฉัย (ฟัตวา) จุฬาราชมนตรี : การชำระล้างหรือทำความสะอาดวัตถุดิบ อุปกรณ์ผ...
Om Muktar
 
Incredible north & south India Tour Packages
Incredible north & south India Tour PackagesIncredible north & south India Tour Packages
Incredible north & south India Tour Packages
Kata Travels
 
Evaluation question 1
Evaluation question 1Evaluation question 1
Evaluation question 1
a2medgroup2
 
Evaluation question 1
Evaluation question 1Evaluation question 1
Evaluation question 1
a2medgroup2
 
2014 Holiday Predictions and Prep List
2014 Holiday Predictions and Prep List2014 Holiday Predictions and Prep List
2014 Holiday Predictions and Prep List
Placeable
 
Focus group magazine feedback
Focus group magazine feedbackFocus group magazine feedback
Focus group magazine feedback
a2medgroup2
 
North India Tour Packages
North India Tour PackagesNorth India Tour Packages
North India Tour Packages
Kata Travels
 
النصيحة هي المسؤولية المشتركة في العمل الدعوي
النصيحة هي المسؤولية المشتركة في العمل الدعويالنصيحة هي المسؤولية المشتركة في العمل الدعوي
النصيحة هي المسؤولية المشتركة في العمل الدعوي
Om Muktar
 
Evidencias 2 parcial powerpoint
Evidencias 2 parcial powerpointEvidencias 2 parcial powerpoint
Evidencias 2 parcial powerpoint
alez5656
 
Fungsi otot
Fungsi ototFungsi otot
Fungsi otot
Priya Shamu
 
Social media toliver
Social media toliverSocial media toliver
Social media toliver
ryantoliver23
 
Questionnaire radio trailer
Questionnaire radio trailer Questionnaire radio trailer
Questionnaire radio trailer
a2medgroup2
 
Focus group documenatry
Focus group documenatry Focus group documenatry
Focus group documenatry
a2medgroup2
 
ذم الأشاعرة والمتكلمين والفلاسفة لأحمد بن الصديق الغماري
ذم الأشاعرة والمتكلمين والفلاسفة لأحمد بن الصديق الغماريذم الأشاعرة والمتكلمين والفلاسفة لأحمد بن الصديق الغماري
ذم الأشاعرة والمتكلمين والفلاسفة لأحمد بن الصديق الغماري
Om Muktar
 
Highlights of south india
Highlights of south indiaHighlights of south india
Highlights of south india
Kata Travels
 
Potential interview
Potential interviewPotential interview
Potential interview
a2medgroup2
 
คำวินิจฉัย (ฟัตวา) จุฬาราชมนตรี : การชำระล้างหรือทำความสะอาดวัตถุดิบ อุปกรณ์ผ...
คำวินิจฉัย (ฟัตวา) จุฬาราชมนตรี : การชำระล้างหรือทำความสะอาดวัตถุดิบ อุปกรณ์ผ...คำวินิจฉัย (ฟัตวา) จุฬาราชมนตรี : การชำระล้างหรือทำความสะอาดวัตถุดิบ อุปกรณ์ผ...
คำวินิจฉัย (ฟัตวา) จุฬาราชมนตรี : การชำระล้างหรือทำความสะอาดวัตถุดิบ อุปกรณ์ผ...
Om Muktar
 
Incredible north & south India Tour Packages
Incredible north & south India Tour PackagesIncredible north & south India Tour Packages
Incredible north & south India Tour Packages
Kata Travels
 
Evaluation question 1
Evaluation question 1Evaluation question 1
Evaluation question 1
a2medgroup2
 
Evaluation question 1
Evaluation question 1Evaluation question 1
Evaluation question 1
a2medgroup2
 
2014 Holiday Predictions and Prep List
2014 Holiday Predictions and Prep List2014 Holiday Predictions and Prep List
2014 Holiday Predictions and Prep List
Placeable
 
Focus group magazine feedback
Focus group magazine feedbackFocus group magazine feedback
Focus group magazine feedback
a2medgroup2
 
North India Tour Packages
North India Tour PackagesNorth India Tour Packages
North India Tour Packages
Kata Travels
 
النصيحة هي المسؤولية المشتركة في العمل الدعوي
النصيحة هي المسؤولية المشتركة في العمل الدعويالنصيحة هي المسؤولية المشتركة في العمل الدعوي
النصيحة هي المسؤولية المشتركة في العمل الدعوي
Om Muktar
 
Evidencias 2 parcial powerpoint
Evidencias 2 parcial powerpointEvidencias 2 parcial powerpoint
Evidencias 2 parcial powerpoint
alez5656
 
Ad

Similar to Arduino section programming slides (20)

Arduino Section Programming - from Sparkfun
Arduino Section Programming - from SparkfunArduino Section Programming - from Sparkfun
Arduino Section Programming - from Sparkfun
JhaeZaSangcapGarrido
 
Arduino for Beginners
Arduino for BeginnersArduino for Beginners
Arduino for Beginners
Sarwan Singh
 
Verilog Lecture2 thhts
Verilog Lecture2 thhtsVerilog Lecture2 thhts
Verilog Lecture2 thhts
Béo Tú
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4
Ismar Silveira
 
Arduino board program for Mobile robotss
Arduino board program for Mobile robotssArduino board program for Mobile robotss
Arduino board program for Mobile robotss
VSARAVANAKUMARHICETS
 
c++ Lecture 3
c++ Lecture 3c++ Lecture 3
c++ Lecture 3
sajidpk92
 
Arduino coding class
Arduino coding classArduino coding class
Arduino coding class
Jonah Marrs
 
Arduino cic3
Arduino cic3Arduino cic3
Arduino cic3
Jeni Shah
 
C++ boot camp part 1/2
C++ boot camp part 1/2C++ boot camp part 1/2
C++ boot camp part 1/2
Jesse Talavera-Greenberg
 
C++ Boot Camp Part 1
C++ Boot Camp Part 1C++ Boot Camp Part 1
C++ Boot Camp Part 1
Jesse Talavera-Greenberg
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programming
The IOT Academy
 
Functions
FunctionsFunctions
Functions
PatriciaPabalan
 
if and else.... Conditional Statement.pptx
if and else.... Conditional Statement.pptxif and else.... Conditional Statement.pptx
if and else.... Conditional Statement.pptx
JhonatanGarciaMendez
 
C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)
jahanullah
 
Dart 1 In Dart, a programming language developed by Google, data types are us...
Dart 1 In Dart, a programming language developed by Google, data types are us...Dart 1 In Dart, a programming language developed by Google, data types are us...
Dart 1 In Dart, a programming language developed by Google, data types are us...
ssuserdb9909
 
Lecture05
Lecture05Lecture05
Lecture05
elearning_portal
 
Loops
LoopsLoops
Loops
Kamran
 
Arduino-arduino arduino programming hhhh
Arduino-arduino arduino programming hhhhArduino-arduino arduino programming hhhh
Arduino-arduino arduino programming hhhh
AbdalkreemZuod
 
What’s new in .NET
What’s new in .NETWhat’s new in .NET
What’s new in .NET
Doommaker
 
Lecture 1 Introduction C++
Lecture 1 Introduction C++Lecture 1 Introduction C++
Lecture 1 Introduction C++
Ajay Khatri
 
Arduino Section Programming - from Sparkfun
Arduino Section Programming - from SparkfunArduino Section Programming - from Sparkfun
Arduino Section Programming - from Sparkfun
JhaeZaSangcapGarrido
 
Arduino for Beginners
Arduino for BeginnersArduino for Beginners
Arduino for Beginners
Sarwan Singh
 
Verilog Lecture2 thhts
Verilog Lecture2 thhtsVerilog Lecture2 thhts
Verilog Lecture2 thhts
Béo Tú
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4
Ismar Silveira
 
Arduino board program for Mobile robotss
Arduino board program for Mobile robotssArduino board program for Mobile robotss
Arduino board program for Mobile robotss
VSARAVANAKUMARHICETS
 
c++ Lecture 3
c++ Lecture 3c++ Lecture 3
c++ Lecture 3
sajidpk92
 
Arduino coding class
Arduino coding classArduino coding class
Arduino coding class
Jonah Marrs
 
Arduino cic3
Arduino cic3Arduino cic3
Arduino cic3
Jeni Shah
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programming
The IOT Academy
 
if and else.... Conditional Statement.pptx
if and else.... Conditional Statement.pptxif and else.... Conditional Statement.pptx
if and else.... Conditional Statement.pptx
JhonatanGarciaMendez
 
C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)
jahanullah
 
Dart 1 In Dart, a programming language developed by Google, data types are us...
Dart 1 In Dart, a programming language developed by Google, data types are us...Dart 1 In Dart, a programming language developed by Google, data types are us...
Dart 1 In Dart, a programming language developed by Google, data types are us...
ssuserdb9909
 
Arduino-arduino arduino programming hhhh
Arduino-arduino arduino programming hhhhArduino-arduino arduino programming hhhh
Arduino-arduino arduino programming hhhh
AbdalkreemZuod
 
What’s new in .NET
What’s new in .NETWhat’s new in .NET
What’s new in .NET
Doommaker
 
Lecture 1 Introduction C++
Lecture 1 Introduction C++Lecture 1 Introduction C++
Lecture 1 Introduction C++
Ajay Khatri
 
Ad

Recently uploaded (20)

May 2025 - Top 10 Read Articles in Artificial Intelligence and Applications (...
May 2025 - Top 10 Read Articles in Artificial Intelligence and Applications (...May 2025 - Top 10 Read Articles in Artificial Intelligence and Applications (...
May 2025 - Top 10 Read Articles in Artificial Intelligence and Applications (...
gerogepatton
 
22PCOAM16 _ML_Unit 3 Notes & Question bank
22PCOAM16 _ML_Unit 3 Notes & Question bank22PCOAM16 _ML_Unit 3 Notes & Question bank
22PCOAM16 _ML_Unit 3 Notes & Question bank
Guru Nanak Technical Institutions
 
New Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docxNew Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docx
misheetasah
 
Class-Symbols for vessels ships shipyards.pdf
Class-Symbols for vessels ships shipyards.pdfClass-Symbols for vessels ships shipyards.pdf
Class-Symbols for vessels ships shipyards.pdf
takisvlastos
 
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
BeHappy728244
 
社内勉強会資料_Chain of Thought .
社内勉強会資料_Chain of Thought                           .社内勉強会資料_Chain of Thought                           .
社内勉強会資料_Chain of Thought .
NABLAS株式会社
 
SEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair KitSEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair Kit
projectultramechanix
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdfIrja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdfRearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Takumi Amitani
 
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra OpticaPruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
OmarAlfredoDelCastil
 
Forecasting Road Accidents Using Deep Learning Approach: Policies to Improve ...
Forecasting Road Accidents Using Deep Learning Approach: Policies to Improve ...Forecasting Road Accidents Using Deep Learning Approach: Policies to Improve ...
Forecasting Road Accidents Using Deep Learning Approach: Policies to Improve ...
Journal of Soft Computing in Civil Engineering
 
MODULE 6 - 1 VAE - Variational Autoencoder
MODULE 6 - 1 VAE - Variational AutoencoderMODULE 6 - 1 VAE - Variational Autoencoder
MODULE 6 - 1 VAE - Variational Autoencoder
DivyaMeenaS
 
A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...
A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...
A Comprehensive Investigation into the Accuracy of Soft Computing Tools for D...
Journal of Soft Computing in Civil Engineering
 
Software Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha TasnuvaSoftware Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha Tasnuva
tanishatasnuva76
 
Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401
Unknown
 
ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025
Rahul
 
Electrical and Electronics Engineering: An International Journal (ELELIJ)
Electrical and Electronics Engineering: An International Journal (ELELIJ)Electrical and Electronics Engineering: An International Journal (ELELIJ)
Electrical and Electronics Engineering: An International Journal (ELELIJ)
elelijjournal653
 
PREDICTION OF ROOM TEMPERATURE SIDEEFFECT DUE TOFAST DEMAND RESPONSEFOR BUILD...
PREDICTION OF ROOM TEMPERATURE SIDEEFFECT DUE TOFAST DEMAND RESPONSEFOR BUILD...PREDICTION OF ROOM TEMPERATURE SIDEEFFECT DUE TOFAST DEMAND RESPONSEFOR BUILD...
PREDICTION OF ROOM TEMPERATURE SIDEEFFECT DUE TOFAST DEMAND RESPONSEFOR BUILD...
ijccmsjournal
 
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Mohamed905031
 
Impurities of Water and their Significance.pptx
Impurities of Water and their Significance.pptxImpurities of Water and their Significance.pptx
Impurities of Water and their Significance.pptx
dhanashree78
 
May 2025 - Top 10 Read Articles in Artificial Intelligence and Applications (...
May 2025 - Top 10 Read Articles in Artificial Intelligence and Applications (...May 2025 - Top 10 Read Articles in Artificial Intelligence and Applications (...
May 2025 - Top 10 Read Articles in Artificial Intelligence and Applications (...
gerogepatton
 
New Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docxNew Microsoft Office Word Documentfrf.docx
New Microsoft Office Word Documentfrf.docx
misheetasah
 
Class-Symbols for vessels ships shipyards.pdf
Class-Symbols for vessels ships shipyards.pdfClass-Symbols for vessels ships shipyards.pdf
Class-Symbols for vessels ships shipyards.pdf
takisvlastos
 
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
Direct Current circuitsDirect Current circuitsDirect Current circuitsDirect C...
BeHappy728244
 
社内勉強会資料_Chain of Thought .
社内勉強会資料_Chain of Thought                           .社内勉強会資料_Chain of Thought                           .
社内勉強会資料_Chain of Thought .
NABLAS株式会社
 
SEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair KitSEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair Kit
projectultramechanix
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdfIrja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdfRearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Takumi Amitani
 
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra OpticaPruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
OmarAlfredoDelCastil
 
MODULE 6 - 1 VAE - Variational Autoencoder
MODULE 6 - 1 VAE - Variational AutoencoderMODULE 6 - 1 VAE - Variational Autoencoder
MODULE 6 - 1 VAE - Variational Autoencoder
DivyaMeenaS
 
Software Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha TasnuvaSoftware Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha Tasnuva
tanishatasnuva76
 
Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401
Unknown
 
ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025
Rahul
 
Electrical and Electronics Engineering: An International Journal (ELELIJ)
Electrical and Electronics Engineering: An International Journal (ELELIJ)Electrical and Electronics Engineering: An International Journal (ELELIJ)
Electrical and Electronics Engineering: An International Journal (ELELIJ)
elelijjournal653
 
PREDICTION OF ROOM TEMPERATURE SIDEEFFECT DUE TOFAST DEMAND RESPONSEFOR BUILD...
PREDICTION OF ROOM TEMPERATURE SIDEEFFECT DUE TOFAST DEMAND RESPONSEFOR BUILD...PREDICTION OF ROOM TEMPERATURE SIDEEFFECT DUE TOFAST DEMAND RESPONSEFOR BUILD...
PREDICTION OF ROOM TEMPERATURE SIDEEFFECT DUE TOFAST DEMAND RESPONSEFOR BUILD...
ijccmsjournal
 
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Numerical Investigation of the Aerodynamic Characteristics for a Darrieus H-t...
Mohamed905031
 
Impurities of Water and their Significance.pptx
Impurities of Water and their Significance.pptxImpurities of Water and their Significance.pptx
Impurities of Water and their Significance.pptx
dhanashree78
 

Arduino section programming slides

  • 1. Code http:/ / arduino.cc/ en/Reference/HomePage
  • 4. Serial Port / COM Port
  • 6. Parts of the Sketch
  • 7. Comments • Comments can be anywhere
  • 8. Comments • Comments can be anywhere • Comments created with / / or / * and * /
  • 9. Comments • Comments can be anywhere • Comments created with / / or / * and * / • Comments do not affect code
  • 10. 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!
  • 11. Operators The equals sign = is used to assign a value == is used to compare values
  • 12. Operators And & Or && is “and” || is “or”
  • 13. Variables Basic variable types: Boolean Integer Character
  • 14. Declaring Variables Boolean: boolean variableName;
  • 15. Declaring Variables Boolean: boolean variableName; Integer: int variableName;
  • 16. Declaring Variables Boolean: boolean variableName; Integer: int variableName; Character: char variableName;
  • 17. Declaring Variables Boolean: boolean variableName; Integer: int variableName; Character: char variableName; String: stringName [ ];
  • 18. Assigning Variables Boolean: variableName = true; or variableName = false;
  • 19. Assigning Variables Boolean: variableName = true; or variableName = false; Integer: variableName = 32767; or variableName = -32768;
  • 20. Assigning Variables Boolean: variableName = true; or variableName = false; Integer: variableName = 32767; or variableName = -32768; Character: variableName = ‘A’; or stringName = “SparkFun”;
  • 21. Variable Scope Where you declare your variables matters
  • 22. Setup void setup ( ) { } The setup function comes before the loop function and is necessary for all Arduino sketches
  • 23. Setup void setup ( ) { } The setup header will never change, everything else that occurs in setup happens inside the curly brackets
  • 24. Setup void setup ( ) { pinMode (13, OUTPUT); } Outputs 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
  • 25. 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...
  • 26. Setup, Internal Pullup Resistors void setup ( ) { digitalWrite (12, HIGH); } You can also create internal pullup resistors in setup, to do so digitalWrite the pin HIGH This takes the place of the pullup resistors currently on your circuit 7 buttons
  • 27. 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
  • 28. 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
  • 29. 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
  • 30. If Statements if ( this is true ) { do this; }
  • 31. If if ( this is true ) { do this; }
  • 32. Conditional if ( this is true ) { do this; }
  • 33. Action if ( this is true ) { do this; }
  • 34. Else else { do this; }
  • 35. Basic Repetition •loop •For •while
  • 36. Basic Repetition void loop ( ) { }
  • 37. Basic Repetition void loop ( ) { }
  • 38. 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
  • 39. 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
  • 40. 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
  • 41. Basic Repetition void loop ( ) { }
  • 42. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here //this could be anything }
  • 43. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here }
  • 44. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here }
  • 45. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here }
  • 46. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here }
  • 47. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here }
  • 48. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here }
  • 49. Basic Repetition while ( count<10 ) { //while action code goes here }
  • 50. 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 }
  • 51. Basic Repetition while ( count<10 ) { //looks basically like a “for” loop //except the variable is declared before //and incremented inside the while //loop }
  • 52. 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 }
  • 54. www.sparkfun.com 6175 Longbow Drive, Suite 200 Boulder, Colorado 80301