11. Introduction to Arduino
11. Introduction to Arduino
RESET
SCL\SDA
(I2C Bus)
POWER
5V / 3.3V / GND
Digital I\O
PWM(3, 5, 6, 9, 10, 11)
Analog
INPUTS
Go ahead and plug your
board in!
SparkFun Inventor’s Kit
Components
Name Image Type Function Notes
Push Button Digital Input Switch - Closes Polarized, needs
or opens circuit resistor
Trim Analog Input Variable resistor Also called a
Trimpot.
potentiometer
Photoresistor Analog Input Light Dependent Resistance varies
Resistor (LDR) with light.
Relay Digital Output Switch driven by Used to control
a small signal larger voltages
control electrical
devices such as
volume controls
on audio
equipment.
SIK Components
The resistance of
a photo
resistor decreases
with increasing incident
light intensity.
Concepts: INPUT vs.
OUTPUT
Referenced from the perspective of the microcontroller (electrical board).
Inputs is a signal / information Output is any signal exiting the
going into the board. board.
Almost all systems that use physical computing will have some form of
output
void setup ( ) { } - All of the code within the curly braces will be
run ONCE when the program first runs.
int (integer) – this stores a number in 2 bytes(16 bits) and has no decimal
places. The value must be between -32,768 and 32,768.
long(long) – Used when the integer is NOT large enough. This takes 4
bytes(32 bits) of RAM and has a range of -2,147,483,648 and
2,147,483,648.
float (float) – Used for floating decimals. It takes 4 bytes of RAM and has
a range of -3.4028235E+38 and 3.4028235E+38
char(character) – Stores one character using ASCII code (“A” = 65). Uses
1 byte of RAM
Programming – Math
Operators
These are used for manipulating numbers.
+ (addition)
- (subtraction)
* (multiplication)
/ (division)
Comparison Operators
These are used to make logical comparisons.
This will execute the code between the curly braces if the
condition is true, and if not test the condition of the “else if”. If that
is false , the “else” code will execute.
Note: There are ways to use the board as analog. Those will be explained later.
Let’s Begin – Learning Goals
Learning Goals: The student will be able to:
1.Build a complete circuit using the Arduino microprocessor
2.Identify important electrical components in a circuit and explain their
use
3.Identify and apply specific elements in “C” code used to run a program
in conjunction with how a circuit is built
Lesson #1 – Blinking LED
What will you need?
Arduino, breadboard, 4 wires, 10mm LED(large
white), 560Ω resistor, USB cable.
Schematic symbol
Resistors
Resistors restrict the amount of electrical
current that can flow through a circuit. The
color bands indicate the VALUE of the
resistor
Note: it is easy to grab the
WRONG one so be careful.
Also, it does not matter which
way the resistor is wired.
Schematic symbol
The schematicThis is basically a SERIES circuit
where the resistor and LED are wired
one after another.