0% found this document useful (0 votes)
9 views15 pages

Lesson 2 - Creating A Series and Parallel Circuit

Uploaded by

cr34mpuff18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views15 pages

Lesson 2 - Creating A Series and Parallel Circuit

Uploaded by

cr34mpuff18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

CREATING A SERIES

AND PARALLEL
CIRCUIT
PROGRAM
MING
The Arduino’s IDE programs
are similar to the C
language. Many C principles
are used in programming
the Arduino, if you have no
background in C
programming language you
don’t need to worry that
much as the proficiency
levels required is just basic.
COMMENT
Comments are how you
explain or inform people
reading your sketch on
what it does. It is a good
practice to put comment on
your sketches, in case you
forgot how the sketch
functions.
• For single line comments,
just add two forward
slashes(//)and this line will
be ignored by the compiler.
• For more than one line
comment use /* at the
start of the comment and
end it with */.
VARIABLES
Variables are used to label and store a piece of data. This
provides us simple way to access, save and change information.
You can declare a variable in different parts of the sketch
depending on where do you want to use it, but often it is placed
at the first few lines. Names of variables must be starting with a
character (does not matter if it is in Capital letters or small
letters) and not with an integer. There are many different types
of a variable and some of the most common variable types are
listed below:
• int: a 16-bit integer. Storing integer means storing
whole numbers. It can hold positive and negative
whole numbers ranging from -32768 to 32767.

• char: an 8-bit variable. Storing char means storing


letters. Interprets as a character like ‘a’ or ‘!’.

• byte: an 8-bit variable representing a number


between 0 and 255.
• boolean: also 8 - bit variable that can only hold
the values High or Low.

• long: a 32-bit integer. Allows us to store values


between -2,147,483,648 to 2,147,483,648.

• float: also a 32- bit variable, that is used in


complicated math since it can store numbers with
decimal places. Once the variable is initialized ,
you won’t need to refer to it using int, just its
name.
FUNCTIONS
These are used to do different procedures in your
program loop. A function text changes to color
orange(if your IDE version is 1.6.0 and below) or
blue (IDE version 1.6.3) when typed correctly, It is
then followed by a bracket or semi colon. Almost
all functions needed user input to have the
desired outcome of the functions, so it is must
placed within the brackets.
In the example above, the first line is a special function that is a
part of every sketch. All commands inside the setup() function are
executed once the program starts and after each power-up or
reset of the Arduino Board. Inside this setup() function is where
you can setup pins whether it is OUTPUT or INPUT variable. You
can also initialized libraries in setup() function.
The first line is also special function that is a part of every sketch and
consider as the heart of most sketches. The loop() function runs
continuously after you have finished the setup(). It allows your program to
change, respond and actively control the Arduino Board. You need to
include both functions in your sketch, even if you don't need them for
anything.
pinMode() is used to configure a pin as either an
input or an output. To use it, you must declare the
number of the pin to configure or the name of the
variable and the constant INPUT or OUTPUT.
When configured as an input, a pin can detect the
state of a sensor like a pushbutton; As an output ,
it can drive any light, sound and actuator
outputs.
digitalWrite() is used to turn digital pins HIGH or
LOW (ON or OFF). To set a pin, you simply state
which pin you would like to change the output
and what state will it be (HIGH or LOW).
delay() caused Arduino to wait or pause for a
length of time (must be in milliseconds) before
continuing on to the next line. In the example,
LED is delayed by 1000 milliseconds (1 second).
WELL
DONE!

You might also like