SlideShare a Scribd company logo
7th – Coding (Project)
Nestor Benavides
Automating something
Every project you try to create using Arduino, will be the reflection of defined
steps, make sure to follow this methodology (first think, then act):
THINK ACT
 What components do you need?
 Which sensors? Which actuators?
 Do you need specific components in specific places?
 Check pins, (+) and GND for each component.
1. Create the circuit.
 Declare the components and variables to use.
 State the sensors, actuators and serial monitor (if
required).
 Program the steps that the producto should follow.
2. Program the circuit.
 Change code and modify the circuit as many times as you
need to, until you have a perfect automated device.
3. Test the circuit and refine.
The code
It is necessary to understand
the whole code, remember
that it does not matter how
many components you have
in your project, you will
always use a code with one
part to declare, then a part
to start the program (void
setup) and finally, a part to
control the components as
desired (void loop).
Declare
Start
Control
Declare
Create space on the top of the code to establish which components you are using
and where they are connected to the Arduino. Follow the structure:
int buzzer1 = 12 ;
Variable’
s type
Variable’s
name
Arduino
connection
Semicolon
Then, create one variable per each sensor that you will use, that variable will
contain the information read by the sensor:
int LDR1reading = 0 ;
Variable’
s type
Variable’s
name (related
to the sensor)
Always
starts in 0
Semicolon
Looks like this
Actuators
Sensors
Variables
TIPS:
• Use the structure, first the
actuators, then the sensors
and finally the variables.
• Use short and easy to
remember names.
• Use names related to the
components that you are
using.
• Same number of sensors and
variables.
Start
In this section, you need to initialize the components and determine if they are
sensors or actuators, also to start the Serial Monitor.
pinMode ( buzzer1 , OUTPUT ) ;
Command Component Comma Sensor or
actuator
Semicolon
After you initialize all the components, start the Serial monitor, always using the
same code:
Serial.begin(9600);
Looks like this
Actuators
Sensors
Serial monitor
TIPS:
• Use the structure, first the
actuators, then the sensors
and finally the Serial monitor.
• OUTPUT = Actuators.
• INPUT = Sensors.
• The commands and variables
must be always written the
same way, capital letters and
lowercase matters.
Control
To control a project, always follow the same structure:
1. Make the sensor sense and store the variables.
2. Show them in the Serial monitor (useful to refine the code).
3. Create the IF/ELSE parameter to make your project take decisions and act.
IF ELSE
if (condition is true) {
action(s) to complete; }
else {
Action(s) to complete; }
If the condition is happening, then act
as required
Under any other circumstance, act as
required.
Control
STEP 1:
STEP 2:
Repeat these 2 steps for as many sensors as you are using in
the program.
LDR1Reading = analogRead ( LDR1 ) ;
CommandVariable Sensor to read
Serial.println ( LDR1Reading ) ;
Command Variable
Semicolon
Semicolon
Looks like this
TIPS:
• Be organized with your code, leave
spaces to have visual advantage.
• Check the changes of colors in the
software, they help you to know if your
capital/lowercase are fine or not.
• Keep in mind that all this is IN THE VOID
LOOP, do not write outside the { }
Control
STEP 3:
Complete as many ifs as you need and remember at the end to use the same
structure for the else, except the comparison part. ONLY ONE ELSE is used.
if ( LDR1Reading < 400 ) {
Command Variable Opening braceComparison Base number
digitalWrite ( buzzer1 , HIGH ) ; }
Command Component State Closing braceSemicolon
Looks like this
IFs
ELSE
TIPS:
• The more components you
use, the more complicated
your code will be.
• You need to know your
sensors and realize if the
readings of them are analog
or digital, before creating the
condition.
• Keep in mind that all this is IN
THE VOID LOOP, do not write
outside the { }
Everything looks like this
TIPS:
• Organize your code.
• Refine the code based on
the behavior of the code
(code, then test, and then
code again until you have
the result that you want).
• Be patient.

More Related Content

Similar to 3.1 coding (project)

arduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdfarduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdf
ssusere5db05
 
Arduino course
Arduino courseArduino course
Arduino course
Ahmed Shelbaya
 
Embedded Application : An Autonomous Robot or Line Follower Bot
Embedded Application : An Autonomous Robot or Line Follower BotEmbedded Application : An Autonomous Robot or Line Follower Bot
Embedded Application : An Autonomous Robot or Line Follower Bot
Er. Raju Bhardwaj
 
Ch_2_8,9,10.pptx
Ch_2_8,9,10.pptxCh_2_8,9,10.pptx
Ch_2_8,9,10.pptx
yosikit826
 
introductiontoarduino-111120102058-phpapp02.pdf
introductiontoarduino-111120102058-phpapp02.pdfintroductiontoarduino-111120102058-phpapp02.pdf
introductiontoarduino-111120102058-phpapp02.pdf
HebaEng
 
Basics of mechatronics - Arduino tutorial
Basics of mechatronics - Arduino tutorialBasics of mechatronics - Arduino tutorial
Basics of mechatronics - Arduino tutorial
ManasShrivastava6
 
Industrial Applications of Arduino using Ladder Logic
Industrial Applications of Arduino using Ladder LogicIndustrial Applications of Arduino using Ladder Logic
Industrial Applications of Arduino using Ladder Logic
Robocraze
 
teststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptxteststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptx
ethannguyen1618
 
publish manual
publish manualpublish manual
publish manual
John Webster
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
Wingston
 
Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and import
iamluqman0403
 
The Basics of programming
The Basics of programmingThe Basics of programming
The Basics of programming
692sfrobotics
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and Robotics
NIT Raipur
 
Basics of arduino uno
Basics of arduino unoBasics of arduino uno
Basics of arduino uno
Rahat Sood
 
Robotics and Automation Using Arduino
Robotics and Automation Using ArduinoRobotics and Automation Using Arduino
Robotics and Automation Using Arduino
ABHISHEKJAISWAL282
 
CO Unit 3.pdf (Important chapter of coa)
CO Unit 3.pdf (Important chapter of coa)CO Unit 3.pdf (Important chapter of coa)
CO Unit 3.pdf (Important chapter of coa)
guptakrishns23
 
Introduction ,characteristics, properties,pseudo code conventions
Introduction ,characteristics, properties,pseudo code conventionsIntroduction ,characteristics, properties,pseudo code conventions
Introduction ,characteristics, properties,pseudo code conventions
swapnac12
 
Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6
Shipra Swati
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
SAURABHKUMAR892774
 
asmaa hosni
asmaa hosniasmaa hosni
asmaa hosni
Asmaa Hosni
 

Similar to 3.1 coding (project) (20)

arduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdfarduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdf
 
Arduino course
Arduino courseArduino course
Arduino course
 
Embedded Application : An Autonomous Robot or Line Follower Bot
Embedded Application : An Autonomous Robot or Line Follower BotEmbedded Application : An Autonomous Robot or Line Follower Bot
Embedded Application : An Autonomous Robot or Line Follower Bot
 
Ch_2_8,9,10.pptx
Ch_2_8,9,10.pptxCh_2_8,9,10.pptx
Ch_2_8,9,10.pptx
 
introductiontoarduino-111120102058-phpapp02.pdf
introductiontoarduino-111120102058-phpapp02.pdfintroductiontoarduino-111120102058-phpapp02.pdf
introductiontoarduino-111120102058-phpapp02.pdf
 
Basics of mechatronics - Arduino tutorial
Basics of mechatronics - Arduino tutorialBasics of mechatronics - Arduino tutorial
Basics of mechatronics - Arduino tutorial
 
Industrial Applications of Arduino using Ladder Logic
Industrial Applications of Arduino using Ladder LogicIndustrial Applications of Arduino using Ladder Logic
Industrial Applications of Arduino using Ladder Logic
 
teststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptxteststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptx
 
publish manual
publish manualpublish manual
publish manual
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
 
Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and import
 
The Basics of programming
The Basics of programmingThe Basics of programming
The Basics of programming
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and Robotics
 
Basics of arduino uno
Basics of arduino unoBasics of arduino uno
Basics of arduino uno
 
Robotics and Automation Using Arduino
Robotics and Automation Using ArduinoRobotics and Automation Using Arduino
Robotics and Automation Using Arduino
 
CO Unit 3.pdf (Important chapter of coa)
CO Unit 3.pdf (Important chapter of coa)CO Unit 3.pdf (Important chapter of coa)
CO Unit 3.pdf (Important chapter of coa)
 
Introduction ,characteristics, properties,pseudo code conventions
Introduction ,characteristics, properties,pseudo code conventionsIntroduction ,characteristics, properties,pseudo code conventions
Introduction ,characteristics, properties,pseudo code conventions
 
Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
asmaa hosni
asmaa hosniasmaa hosni
asmaa hosni
 

More from Nestor Benavides

Sculptris
SculptrisSculptris
Sculptris
Nestor Benavides
 
Domotics: New Arduino components
Domotics: New Arduino componentsDomotics: New Arduino components
Domotics: New Arduino components
Nestor Benavides
 
Marketing and products creation
Marketing and products creationMarketing and products creation
Marketing and products creation
Nestor Benavides
 
Designing products and automation
Designing products and automationDesigning products and automation
Designing products and automation
Nestor Benavides
 
Line follOwer
Line follOwerLine follOwer
Line follOwer
Nestor Benavides
 
Resistors and breadboard
Resistors and breadboardResistors and breadboard
Resistors and breadboard
Nestor Benavides
 
Electricity and basic components
Electricity and basic componentsElectricity and basic components
Electricity and basic components
Nestor Benavides
 
5. conditionals
5. conditionals5. conditionals
5. conditionals
Nestor Benavides
 
4. sensors
4. sensors4. sensors
4. sensors
Nestor Benavides
 
Welcome myp
Welcome mypWelcome myp
Welcome myp
Nestor Benavides
 
Welcome PYP
Welcome PYPWelcome PYP
Welcome PYP
Nestor Benavides
 

More from Nestor Benavides (11)

Sculptris
SculptrisSculptris
Sculptris
 
Domotics: New Arduino components
Domotics: New Arduino componentsDomotics: New Arduino components
Domotics: New Arduino components
 
Marketing and products creation
Marketing and products creationMarketing and products creation
Marketing and products creation
 
Designing products and automation
Designing products and automationDesigning products and automation
Designing products and automation
 
Line follOwer
Line follOwerLine follOwer
Line follOwer
 
Resistors and breadboard
Resistors and breadboardResistors and breadboard
Resistors and breadboard
 
Electricity and basic components
Electricity and basic componentsElectricity and basic components
Electricity and basic components
 
5. conditionals
5. conditionals5. conditionals
5. conditionals
 
4. sensors
4. sensors4. sensors
4. sensors
 
Welcome myp
Welcome mypWelcome myp
Welcome myp
 
Welcome PYP
Welcome PYPWelcome PYP
Welcome PYP
 

Recently uploaded

The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 

Recently uploaded (20)

The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 

3.1 coding (project)

  • 1. 7th – Coding (Project) Nestor Benavides
  • 2. Automating something Every project you try to create using Arduino, will be the reflection of defined steps, make sure to follow this methodology (first think, then act): THINK ACT  What components do you need?  Which sensors? Which actuators?  Do you need specific components in specific places?  Check pins, (+) and GND for each component. 1. Create the circuit.  Declare the components and variables to use.  State the sensors, actuators and serial monitor (if required).  Program the steps that the producto should follow. 2. Program the circuit.  Change code and modify the circuit as many times as you need to, until you have a perfect automated device. 3. Test the circuit and refine.
  • 3. The code It is necessary to understand the whole code, remember that it does not matter how many components you have in your project, you will always use a code with one part to declare, then a part to start the program (void setup) and finally, a part to control the components as desired (void loop). Declare Start Control
  • 4. Declare Create space on the top of the code to establish which components you are using and where they are connected to the Arduino. Follow the structure: int buzzer1 = 12 ; Variable’ s type Variable’s name Arduino connection Semicolon Then, create one variable per each sensor that you will use, that variable will contain the information read by the sensor: int LDR1reading = 0 ; Variable’ s type Variable’s name (related to the sensor) Always starts in 0 Semicolon
  • 5. Looks like this Actuators Sensors Variables TIPS: • Use the structure, first the actuators, then the sensors and finally the variables. • Use short and easy to remember names. • Use names related to the components that you are using. • Same number of sensors and variables.
  • 6. Start In this section, you need to initialize the components and determine if they are sensors or actuators, also to start the Serial Monitor. pinMode ( buzzer1 , OUTPUT ) ; Command Component Comma Sensor or actuator Semicolon After you initialize all the components, start the Serial monitor, always using the same code: Serial.begin(9600);
  • 7. Looks like this Actuators Sensors Serial monitor TIPS: • Use the structure, first the actuators, then the sensors and finally the Serial monitor. • OUTPUT = Actuators. • INPUT = Sensors. • The commands and variables must be always written the same way, capital letters and lowercase matters.
  • 8. Control To control a project, always follow the same structure: 1. Make the sensor sense and store the variables. 2. Show them in the Serial monitor (useful to refine the code). 3. Create the IF/ELSE parameter to make your project take decisions and act. IF ELSE if (condition is true) { action(s) to complete; } else { Action(s) to complete; } If the condition is happening, then act as required Under any other circumstance, act as required.
  • 9. Control STEP 1: STEP 2: Repeat these 2 steps for as many sensors as you are using in the program. LDR1Reading = analogRead ( LDR1 ) ; CommandVariable Sensor to read Serial.println ( LDR1Reading ) ; Command Variable Semicolon Semicolon
  • 10. Looks like this TIPS: • Be organized with your code, leave spaces to have visual advantage. • Check the changes of colors in the software, they help you to know if your capital/lowercase are fine or not. • Keep in mind that all this is IN THE VOID LOOP, do not write outside the { }
  • 11. Control STEP 3: Complete as many ifs as you need and remember at the end to use the same structure for the else, except the comparison part. ONLY ONE ELSE is used. if ( LDR1Reading < 400 ) { Command Variable Opening braceComparison Base number digitalWrite ( buzzer1 , HIGH ) ; } Command Component State Closing braceSemicolon
  • 12. Looks like this IFs ELSE TIPS: • The more components you use, the more complicated your code will be. • You need to know your sensors and realize if the readings of them are analog or digital, before creating the condition. • Keep in mind that all this is IN THE VOID LOOP, do not write outside the { }
  • 13. Everything looks like this TIPS: • Organize your code. • Refine the code based on the behavior of the code (code, then test, and then code again until you have the result that you want). • Be patient.