SlideShare a Scribd company logo
STREAM:
CIRCUITS AND IOT WITH ARDUINO
THINK-PAIR-SHARE
B
Arrays
 An array is a collection of variables with the same data types. It is a very
useful enhancement to variables that allows a single variable name to
store multiple values. To access the stored information inside an array,
the location of the data needs to be specified when using an array. This
location is also known as the Index of the array and the stored
information inside the array is called Elements. The index of an array
always starts the counting from Zero.
Array
 • int – is a variable data type that can store whole numbers.
• ledPin - is the variable name. This follows the rules when naming
variables.
• [ ] Square Brackets - After the variable name, a set of square brackets
must be put with a number inside of it. This number represents the size
of the array, also known as the number of "Elements” inside an
array.
 ; semicolon - A semicolon is placed after the square brackets to indicate
the end of the statement.
Array
With this example, we have 5 elements that can store integer information. If
we want to access the first element, we need to call index zero. Just like this:
ledPin [0]
Since the index starts at zero and we only have 5 elements inside the array,
we can say:
Array
If we want to store information in every element, we can
declare in the parameter:
ledPin [0]
ledPin [1]
ledPin [2]
ledPin [3]
ledPin [4]
Similar to a regular variable, an array must be declared
before it can be used.
How do we initialize an array?
 When an array is used in a function, typically it is not assigned yet will
values. With this, we can call the index of the array and store
information, just like the example given above. In other cases, arrays
can be explicitly given values. These values need to be inside a set of
curly braces after an equal symbol.
 For example:
int ledPin [5] = {2, 3, 4, 5, 8};
This line of code is similar to:
How do we initialize an array?
 Where:
 • = Equal symbol - is used to assign values to an array.
 • { } Curly Braces - The elements of an array need to be stored inside a
set of curly braces to define the start and end of a code block.
 • , Comma - The elements inside an array needs to be separated with a
comma. In C and C++, commas are used as a separator of definitions
and function calls.
How do we initialize an array?
 With this example, we have 5 elements that can store integer
information. If we want to access the second element, we need to call
index one. Just like this:
ledPin [1]
 With the evolution of C++, it has led to the adoption of universal
initialization also for arrays. An equal sign can no longer be used
between the declaration and the initialized values. The following
examples are similar:
 int ledPin [5] = {2, 3, 4, 5, 8};
Accessing the Values in an Array
How can we access the values stored in an Array?
The values inside an array can be accessed similar to
how the values of regular variables are accessed with the
same data type.
For example:
int ledPin [5];
Just like our example previously, this is similar to:
Accessing the Values in an Array
If we want to store integer information in Index 1, we can
do it like this:
ledPin [1] = 3;
An array with a specified index that was previously stored
with information, can be used also to assign values to other
declared values.
For example,
ledPin [1] = 3;
Array Programming Example
Circuit Diagram
Array Programming Example
For the code, copy the program shown below. It will light up the LED lights, and it
will explain further the use of arrays in programming.
 int ledPins [5] = {3,5,6,9};
 void setup()
 {
 pinMode (ledPins [0],OUTPUT);
 pinMode (ledPins [1],OUTPUT);
 pinMode (ledPins [2],OUTPUT);
 pinMode (ledPins [3],OUTPUT);
 }
Array Programming Example
 void loop ()
 {
 analogWrite (ledPins [0],HIGH);
 analogWrite (ledPins [1],HIGH);
 analogWrite (ledPins [2],HIGH);
 analogWrite (ledPins [3],HIGH);
 delay (1000);
 }
TRANSFER
 Using the Diagram below create a program using array function
which will make the led turn ON with 1 second ( 1000) delay and
upload it in the arduino to test the program.
Assignment:
 On a short coupon bond, using the diagram provided, write a the
appropriate program using array function putting the led ON with a 1000
(1 second) delay and OFF with a 2000 (2 seconds) delay. Present to the
class tomorrow.

More Related Content

Similar to DEMO.ppt

ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
MamataAnilgod
 
ppt on arrays in c programming language.pptx
ppt on arrays in c programming language.pptxppt on arrays in c programming language.pptx
ppt on arrays in c programming language.pptx
AmanRai352102
 
Arrays accessing using for loops
Arrays accessing using for loopsArrays accessing using for loops
Arrays accessing using for loops
sangrampatil81
 
Programming fundamentals week 12.pptx
Programming fundamentals week 12.pptxProgramming fundamentals week 12.pptx
Programming fundamentals week 12.pptx
dfsdg3
 
Introduction to Arrays in C
Introduction to Arrays in CIntroduction to Arrays in C
Introduction to Arrays in C
Thesis Scientist Private Limited
 
Arrays.pptx
 Arrays.pptx Arrays.pptx
Arrays.pptx
PankajKumar497975
 
Pandas csv
Pandas csvPandas csv
Pandas csv
Devashish Kumar
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
KristinaBorooah
 
c++ arrays and pointers grade 9 STEP curriculum.pptx
c++ arrays and pointers grade 9 STEP curriculum.pptxc++ arrays and pointers grade 9 STEP curriculum.pptx
c++ arrays and pointers grade 9 STEP curriculum.pptx
JanineCallangan
 
Cunit3.pdf
Cunit3.pdfCunit3.pdf
Cunit3.pdf
zeenatparveen24
 
Chapter-Five.pptx
Chapter-Five.pptxChapter-Five.pptx
Chapter-Five.pptx
berekethailu2
 
12000121037.pdf
12000121037.pdf12000121037.pdf
12000121037.pdf
AVIWORLD1
 
Unit ii data structure-converted
Unit  ii data structure-convertedUnit  ii data structure-converted
Unit ii data structure-converted
Shri Shankaracharya College, Bhilai,Junwani
 
Homework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdfHomework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdf
aroraopticals15
 
java.pdf
java.pdfjava.pdf
java.pdf
RAJCHATTERJEE24
 
Arrays in c v1 09102017
Arrays in c v1 09102017Arrays in c v1 09102017
Arrays in c v1 09102017
Tanmay Modi
 
Arrays in c language
Arrays in c languageArrays in c language
Arrays in c language
tanmaymodi4
 
Arraysincv109102017 180831194256
Arraysincv109102017 180831194256Arraysincv109102017 180831194256
Arraysincv109102017 180831194256
ABHAY9616302301
 
unit1Intro_final.pptx
unit1Intro_final.pptxunit1Intro_final.pptx
unit1Intro_final.pptx
DEEPAK948083
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
SajalFayyaz
 

Similar to DEMO.ppt (20)

ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
 
ppt on arrays in c programming language.pptx
ppt on arrays in c programming language.pptxppt on arrays in c programming language.pptx
ppt on arrays in c programming language.pptx
 
Arrays accessing using for loops
Arrays accessing using for loopsArrays accessing using for loops
Arrays accessing using for loops
 
Programming fundamentals week 12.pptx
Programming fundamentals week 12.pptxProgramming fundamentals week 12.pptx
Programming fundamentals week 12.pptx
 
Introduction to Arrays in C
Introduction to Arrays in CIntroduction to Arrays in C
Introduction to Arrays in C
 
Arrays.pptx
 Arrays.pptx Arrays.pptx
Arrays.pptx
 
Pandas csv
Pandas csvPandas csv
Pandas csv
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
c++ arrays and pointers grade 9 STEP curriculum.pptx
c++ arrays and pointers grade 9 STEP curriculum.pptxc++ arrays and pointers grade 9 STEP curriculum.pptx
c++ arrays and pointers grade 9 STEP curriculum.pptx
 
Cunit3.pdf
Cunit3.pdfCunit3.pdf
Cunit3.pdf
 
Chapter-Five.pptx
Chapter-Five.pptxChapter-Five.pptx
Chapter-Five.pptx
 
12000121037.pdf
12000121037.pdf12000121037.pdf
12000121037.pdf
 
Unit ii data structure-converted
Unit  ii data structure-convertedUnit  ii data structure-converted
Unit ii data structure-converted
 
Homework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdfHomework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdf
 
java.pdf
java.pdfjava.pdf
java.pdf
 
Arrays in c v1 09102017
Arrays in c v1 09102017Arrays in c v1 09102017
Arrays in c v1 09102017
 
Arrays in c language
Arrays in c languageArrays in c language
Arrays in c language
 
Arraysincv109102017 180831194256
Arraysincv109102017 180831194256Arraysincv109102017 180831194256
Arraysincv109102017 180831194256
 
unit1Intro_final.pptx
unit1Intro_final.pptxunit1Intro_final.pptx
unit1Intro_final.pptx
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 

Recently uploaded

INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLESINTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
anfaltahir1010
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
Karya Keeper
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
Maitrey Patel
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
The Third Creative Media
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
ISH Technologies
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
VALiNTRY360
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
Reetu63
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
Quarter 3 SLRP grade 9.. gshajsbhhaheabh
Quarter 3 SLRP grade 9.. gshajsbhhaheabhQuarter 3 SLRP grade 9.. gshajsbhhaheabh
Quarter 3 SLRP grade 9.. gshajsbhhaheabh
aisafed42
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 

Recently uploaded (20)

INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLESINTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
Quarter 3 SLRP grade 9.. gshajsbhhaheabh
Quarter 3 SLRP grade 9.. gshajsbhhaheabhQuarter 3 SLRP grade 9.. gshajsbhhaheabh
Quarter 3 SLRP grade 9.. gshajsbhhaheabh
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 

DEMO.ppt

  • 3. Arrays  An array is a collection of variables with the same data types. It is a very useful enhancement to variables that allows a single variable name to store multiple values. To access the stored information inside an array, the location of the data needs to be specified when using an array. This location is also known as the Index of the array and the stored information inside the array is called Elements. The index of an array always starts the counting from Zero.
  • 4. Array  • int – is a variable data type that can store whole numbers. • ledPin - is the variable name. This follows the rules when naming variables. • [ ] Square Brackets - After the variable name, a set of square brackets must be put with a number inside of it. This number represents the size of the array, also known as the number of "Elements” inside an array.  ; semicolon - A semicolon is placed after the square brackets to indicate the end of the statement.
  • 5. Array With this example, we have 5 elements that can store integer information. If we want to access the first element, we need to call index zero. Just like this: ledPin [0] Since the index starts at zero and we only have 5 elements inside the array, we can say:
  • 6. Array If we want to store information in every element, we can declare in the parameter: ledPin [0] ledPin [1] ledPin [2] ledPin [3] ledPin [4] Similar to a regular variable, an array must be declared before it can be used.
  • 7. How do we initialize an array?  When an array is used in a function, typically it is not assigned yet will values. With this, we can call the index of the array and store information, just like the example given above. In other cases, arrays can be explicitly given values. These values need to be inside a set of curly braces after an equal symbol.  For example: int ledPin [5] = {2, 3, 4, 5, 8}; This line of code is similar to:
  • 8. How do we initialize an array?  Where:  • = Equal symbol - is used to assign values to an array.  • { } Curly Braces - The elements of an array need to be stored inside a set of curly braces to define the start and end of a code block.  • , Comma - The elements inside an array needs to be separated with a comma. In C and C++, commas are used as a separator of definitions and function calls.
  • 9. How do we initialize an array?  With this example, we have 5 elements that can store integer information. If we want to access the second element, we need to call index one. Just like this: ledPin [1]  With the evolution of C++, it has led to the adoption of universal initialization also for arrays. An equal sign can no longer be used between the declaration and the initialized values. The following examples are similar:  int ledPin [5] = {2, 3, 4, 5, 8};
  • 10. Accessing the Values in an Array How can we access the values stored in an Array? The values inside an array can be accessed similar to how the values of regular variables are accessed with the same data type. For example: int ledPin [5]; Just like our example previously, this is similar to:
  • 11. Accessing the Values in an Array If we want to store integer information in Index 1, we can do it like this: ledPin [1] = 3; An array with a specified index that was previously stored with information, can be used also to assign values to other declared values. For example, ledPin [1] = 3;
  • 13. Array Programming Example For the code, copy the program shown below. It will light up the LED lights, and it will explain further the use of arrays in programming.  int ledPins [5] = {3,5,6,9};  void setup()  {  pinMode (ledPins [0],OUTPUT);  pinMode (ledPins [1],OUTPUT);  pinMode (ledPins [2],OUTPUT);  pinMode (ledPins [3],OUTPUT);  }
  • 14. Array Programming Example  void loop ()  {  analogWrite (ledPins [0],HIGH);  analogWrite (ledPins [1],HIGH);  analogWrite (ledPins [2],HIGH);  analogWrite (ledPins [3],HIGH);  delay (1000);  }
  • 15. TRANSFER  Using the Diagram below create a program using array function which will make the led turn ON with 1 second ( 1000) delay and upload it in the arduino to test the program.
  • 16. Assignment:  On a short coupon bond, using the diagram provided, write a the appropriate program using array function putting the led ON with a 1000 (1 second) delay and OFF with a 2000 (2 seconds) delay. Present to the class tomorrow.