Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

VARIABLES, DATA TYPES, BREADBOARD, LED

AND RESISTOR

Variables

• A symbol or name that stands for a value. A variable is a


value that can change.

• Variables provide temporary storage for information that


will be needed during the lifespan of the computer
program (or application)

Example: Z=X+Y
This is an example of programming expression. x, y and z
are variables. Variables can represent numeric values,
characters, character strings, or memory addresses.

Variables store everything in your program. The purpose


of any useful program is to modify variables.

In a program every, variable has:


-Name(Identifier)
– Data Type
– Value
Rules in Naming a Variable

Declaration
Data Type Variable Name(Identifier) = Value;

Statement and Operators:


Statement represents a command, it ends with ;
Ex:
• int x;
• x=13;

Operators are symbols that used to indicate a specific function:


• Math operators: [+,-,*,/,%,^]
• Logic operators: [==, !=, &&, ||]
• Comparison operators: [==, >, <, !=, <=, >=]
• Compound Operators:
• ++ (increment)
• -- (decrement)
• += (compound addition)
• -= (compound subtraction)
• *= (compound multiplication)
• /= (compound division)
1 – Short pin to be connected
to GND (ground)
BREADBOARD 2 – Longer pin to be
is used to create circuits and connectconnected
different sensors and
to any of the digital
actuators to the Arduino board it alsopins
refers – 13)
to a2 solderless
(pins
breadboard.

Resistor- are electronic components that limit the current with


some value of resistance. Resistance blocks the flow of
electricity. The bigger the value of resistance, the little
flow of electricity and vice versa. They are passive
components, meaning they only consume power (and cannot
generate it). Commonly resistors are used to limit current,
divide voltage, and pull-up I/O lines.

Resistor Color Codes


• Resistors resist the flow of electrical current. Each one has a
value that tells how strongly it resists current flow. This
value's unit is the ohm, often noted with the Greek letter
omega: Ω..
• 1 – Serial connection from positive 1 to 30 is used to • The colored bands on a resistor can tell you everything you
need to know about its value and tolerance, as long as you
connect the horizontal pins which is called power rails.
understand how to read them. The order in which the colors
The connection on the blue line rail is different from the
are arranged is very important, and each value of resistor has
red line rail.
its own unique combination.
• 2 – Serial connection from A1, B1, C1, D1 and E1 is used
to connect the vertical pins

• 3 – Trench serves a very important purpose, if a dual in-


line package or DIP chip is used,
there is a separation of
connection is made so that if
connection is made to each side
of the IC there will be no
interference between the
functionality of the leg on the
opposite side.

“Light Emitting Diode”

In short, LEDs are like tiny


light bulbs. However, LEDs require a lot less power to
light up by comparison.
inside the parenthesis ( ) are the pin that needs to be
controlled and it can be set either HIGH or LOW */
Tolerance Band
• The fourth color band indicates the delay(3000);
resistor's tolerance. Tolerance is the percentage of error in the /* delay ( ) is the function in controlling digital device, inside
resistor's resistance, or how much more or less you can expect the parenthesis ( ) are the pin that needs to be controlled
a resistor's actual measured resistance to be from its stated and it can be set either HIGH or LOW */
resistance. A gold tolerance band is 5% tolerance, silver is digitalWrite(LED, LOW);
10%, and no band at all would mean a 20% tolerance.
For example: delay(2000);
• A 220 Ω resistor has a silver tolerance band.
}
• Tolerance = value of resistor x value of tolerance band =
220 Ω x 10% = 22 Ω
• 220 Ω stated resistance +/- 22 Ω tolerance means that the
resistor could range in actual value from as much as 242
Ω to as little as 198 Ω.

LIGHT EMITTING DIODE - LED

1 – short pin to be connected to GND (ground)


2 – longer pin to be connected to any of the digital pins
(pins 2 – 19)

int LED = 2;
/* int means integer, LED is a variable that will be used to
represent the device connected on the microcontroller and
assigning 2 as the value for pin 2*/

void setup( ) {
// put your setup code here, to run once:

pinMode(LED, OUTPUT);
/* pinMode is a function that prepares ALL the pins used in
the microcontroller. Variable LED is the same as 2 thus, pin 2
will be used as an OUTPUT device */

void loop( ) {

// put your main code here, to run repeatedly:

digitalWrite(LED, HIGH);
/* digitalWrite ( ) is the function in controlling digital device,

You might also like