You are on page 1of 84

IO

R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
( P
W
M
~
)
O
N
I S
P
T
X
R
X
SIK GUIDE
Your guide to the SparkFun Inventors Kit for the SparkFun RedBoard
I
O
R
E
F
R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L
S
C
A
A
R
E
F
G
N
D
1
3
1
2
~
1
1
~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.
3
V
5
V
G
N
D
G
N
D
V
I
N
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G

I
N
D
I
G
I
T
A
L

(
P
W
M
~
)
O
N
I
S
P
T
X
R
X
A
R
D
U
I
N
O

L
A
N
G
U
A
G
E

D
E
V
E
L
O
P
M
E
N
T

P
L
A
T
F
O
R
M
Version 3.0
Te SparkFun Inventor's Guide is your map for navigating the
waters of beginning embedded electronics. Tis booklet contains
all the information you will need to explore the 15 circuits of the
SparkFun Inventor's Kit for Educators. At the center of this
manual is one core philosophy - that anyone can (and should)
play around with electronics. When you're done with this guide,
you'll have the know-how to start creating your own projects and
experiments. Now enough talking - let's get inventing!
www.sparkfun.com
Welcome to the SparkFun Inventors Guide
Table of Contents
What is the RedBoard platform? 1
Download Arduino Software (IDE) 3
Install Drivers 4
Identify Your Hardware 7
Download SIK Guide Code 8
The World Runs on Circuits 9
Inventory of Parts 11
13
15
17
24
28
32
36
40
44
48
52
Section 2: Getting Started with Circuits
Section 1: Getting Started
RedBoard
Breadboard
Circuit #1 - Your First Circuit: Blinking a LED
Circuit #3 - RGB LED
Circuit #4 - Multiple LEDs
Circuit #5 - Push Buttons
Circuit #6 - Photo Resistor
Circuit #7 - Temperature Sensor
Circuit #8 - A Single Servo
Circuit #9 - Flex Sensor
56 Circuit #10 - Soft Potentiometer
60 Circuit #11 - Piezo Element
64 Circuit #12 - Spinning a Motor
68 Circuit #13 - Relay
72 Circuit #14 - Shift Register
76 Circuit #15 - LCD
Circuit #2 - Potentiometer
We live in a unique time where we have access to resources
that allow us to create our own solutions and inventions. Te
DIY revolution is composed of hobbyists, tinkerers and
inventors who would rather craft their own projects than let
someone do it for them.
www.sparkfun.com
The DIY Revolution
What is the RedBoard platform?
FPO
FPO
Te RedBoard in your hand (or on your desk) is your
development platform. At its roots, the RedBoard is
essentially a small portable computer. It is capable of
taking inputs (such as the push of a button or a reading
from a light sensor) and interpreting that information to
control various outputs (like a blinking LED light or an
electric motor).
Tat's where the term "physical computing" is born -
this board is capable of taking the world of electronics
and relating it to the physical world in a real and tangible
way. Trust us - this will all make more sense soon.
A Computer for the Physical World
RedBoard
// SparkFun RedBoard
Te SparkFun RedBoard is one of a multitude of
development boards based on the ATmega328. It has 14
digital input/output pins (6 of which can be PWM
outputs), 6 analog inputs, a 16 MHz crystal oscillator, a
USB connection, a power jack, an ISP header, and a reset
button. Dont worry, youll learn about all these later.
IOREF
RESET
R
E
S
E
T
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
1
0
T
X
R
X
1
3
3.3V
5V
GND
GND
VIN
A0
A1
A2
A3
A4
A5
P
O
W
E
R
A
N
A
L
O
G

I
N
D
I
G
I
T
A
L

(
P
W
M
~
)
O
N
I
S
P
TX
RX
c
b
a
d
e
f
g
h
c
b
a
f
e
d
h
g
Power-Lacing High Tops
Old Toy Email Notifer
Bug Zapper Counter
Re-Programmed Trafc Light
Auto-Plant Watering
Camera Time-lapse operation
Quadcopter
Auto-Coffee Maker
RedBoard
In order to get your RedBoard up and running, you'll need to
download the newest version of the Arduino software frst from
www.arduino.cc (it's free!). Tis software, known as the Arduino
IDE, will allow you to program the board to do exactly what you
want. Its like a word processor for writing programs. With an
internet-capable computer, open up your favorite browser and
type in the following URL into the address bar:
Access the Internet
Download the Arduino IDE
(Integrated Development Environment)
user

Windows
Mac OS X
Linux: 32 bit, 64 bit
N
W
S
E
NW
S W
S E
NE
arduino.cc/en/main/software
Choose the appropriate Operating System installation package for your computer.
Download
Click on your appropriate computer
operating system next to the + sign.
Windows
Mac OS X
source
Linux: 32 bit, 64 bit
1
// Connect your RedBoard to your Computer
Use the USB cable provided in the SIK kit to connect the RedBoard to
one of your computers USB inputs.
// Install Arduino Drivers
Depending on your computers operating system, you will need to follow specifc
instructions. Please go to https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers
for specifc instructions on how to install the FTDI drivers onto your RedBoard.
2
3
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
( P
W
M
~
)
O
N
I S
P
T
X
R
X
1 2 3 5 6
7
8
9
4
Open the Arduino IDE software on your computer. Poke around and get to know
the interface. We arent going to code right away, this is just an introduction. Tis
step is to set your IDE to identify your RedBoard.
// Open the Arduino IDE:
// The three most important commands for this guide are seen below:
GUI (Graphical User Interface)
Verify: Compiles and approves your code. It will catch errors in syntax (like missing semi-colons or parenthesis). // See Diagram Below 1
Upload: Sends your code to the RedBoard. When you click it, you should see the lights on your board blink rapidly. // See Diagram Below 2
New: This buttons opens up a new code window tab. 3
Open: This button will let you open up an existing sketch. // See Diagram Below 4
Save: This saves the currently active sketch. 5
Serial Monitor: This will open a window that displays any serial information your RedBoard is transmitting. It is very useful for debugging. 6
Code Area: This is the area where you compose the code for your sketch. 8
Message Area: This is where the IDE tells you if there were any errors in your code. 9
Sketch Name: This shows the name of the sketch you are currently working on. 7
Verify
Upload
Open
File Edit Sketch Tools Help
Auto Format
Archive Sketch
Fix Encoding & Reload
Serial Monitor
Arduino Uno
Arduino Duemilanove w/ ATmega328]
Arduino Diecimila or Duemilanove w/ ATmega168
Arduino Nano w/ ATmega328
Arduino Nano w/ ATmega168
Arduino Mega 2560 or Mega ADK
Arduino Mega (ATmega1280)
Arduino Mini
Arduino Mini w/ATmega168
Arduino Ethernet
Arduino Fio
Arduino BT w/ ATmega328
Arduino BT w/ATmega168
LilyPad Arduino w/ ATmega328
LilyPad Arduino w/ ATmega168
Arduino Pro or Pro Mini (5V, 16 MHz) w/ATmega328
Arduino Pro or Pro Mini (5V, 16 MHz) w/ATmega168
Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ATmega328
Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ATmega168
Arduino NG or older w/ ATmega168
Arduino NG or older w/ ATmega8
Programmer
Burn Bootloader
Board
Serial Port
// Select your board: Arduino Uno
Select the serial device of the RedBoard from the Tools |
Serial Port menu. Tis is likely to be com3 or higher
(COM1 and COM2 are usually reserved for hardware
serial ports). To fnd out, you can disconnect your
RedBoard and re-open the menu; the entry that
disappears should be the RedBoard. Reconnect the
board and select that serial port.
Select the serial device of the RedBoard from the Tools
> Serial Port menu. On the Mac, this should be
something with /dev/tty.usbmodem or
/dev/tty.usbserial in it.
http://www.arduino.cc/playground/Learning/Linux
Tools Help
Auto Format
Archive Sketch
Fix Encoding & Reload
Serial Monitor
com 1
com 12
Programmer
Burn Bootloader
Board
Serial Port
Tools Help
Auto Format
Archive Sketch
Fix Encoding & Reload
Serial Monitor
/dev/tty.usbmodem262471
/dev/cu.usbmodem262471
/dev/tty.Bluetooth-Modem
/dev/cu.Bluetooth-Modem
/dev/tty.FireFly-7256-SPP
/dev/cu.FireFly-7256-SPP
/dev/tty.tiPhone-WirelessiAP-1
/dev/cu.tiPhone-WirelessiAP-1
/dev/tty.Bluetooth-PDA-Sync
/dev/cu.Bluetooth-PDA-Sync
Programmer
Burn Bootloader
Board
Serial Port
/
/

S
e
l
e
c
t

y
o
u
r

S
e
r
i
a
l

D
e
v
i
c
e
4
Note:
Your SparkFun RedBoard and the
Arduino UNO are interchangeable
but you wont nd the RedBoard
listed in the Arduino Software.
Select Arduino UNO instead.
Type in the following URL to download the code:
Download Arduino Code
(For use with the circuits in this guide)
sparkfun.com/sikcode
5
Unzip the fle SIK Guide Code. It
should be located in your browsers
Downloads folder. Right click the
zipped folder and choose unzip.
Copy the SIK Guide Code folder into Arduinos
folder named examples.
Copy the SIK Guide Code folder into
Arduinos folder named examples.
WHATS NEXT? Read on to learn more about getting started with circuits. Ten you can start on your frst circuit on page 17!
Unzip the fle SIK Guide Code. It
should be loacted in your browsers
Downloads folder. Right click the
zipped folder and choose unzip.
Find Arduino in your applications
folder. Right click(ctrl + click) on
Arduino. Select Show Package
Contents.
http://www.arduino.cc/playground/Learning/Linux
/
/

C
o
p
y

S
I
K

G
u
i
d
e

C
o
d
e


i
n
t
o

E
x
a
m
p
l
e
s


l
i
b
r
a
r
y

i
n

A
r
d
u
i
n
o

f
o
l
d
e
r
Programs Start arduino examples
Contents
Resources
Java
examples
Arduino
Move to Trash
Open
Show Package Contents
Everywhere you look, you'll fnd circuits. Te cell
phone in your pocket, the computer that controls
your car's emissions system, your video game
console - all these things are chock full of circuits.
In this guide, you'll experiment with some simple
circuits and learn the gist of the world of embedded
electronics.
The World Runs on Circuits:
Getting Started with Circuits
A circuit is basically an electrical loop with a starting point and an
ending point - with any number of components in between.
Circuits can include resistors, diodes, inductors, sensors of all sizes
and shapes, motors, and any other handful of hundreds of
thousands of components.
Circuits are usually divided into three categories - analog circuits,
digital circuits, or mixed-signal circuits. In this guide, you will
explore all three sets of circuits.
What is an Electrical Circuit?
// Simple and Complex Circuits
In this guide, you will be primarily exploring
simple circuits - but that doesn't mean you can't
do amazing things with simple tools! When you've
fnished the SIK, your knowledge of circuits will
enable you to explore amazing projects and
unleash the power of your imagination.
a b c d e f g h i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
a b c d e f g h i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Inventory of Parts
* ACTUAL SIZE
(1N4148)
Diode
x2
x1
Piezo Element
Various Colors
Jumper Wire
x30
Push Button
x2
x1
DC Motor
x1
DC Motor
x1
Potentiometer
(Light Emitting Diode)
x10 x10 x1
LED (5mm)
+
-
330 Resistor
x25
* ACTUAL SIZE
10K Resistor
x25
* ACTUAL SIZE
(TMP36)
x1
Temp. Sensor
FRONT
BACK
(P2N2222AG)
x2
Transistor
P
2
N
2
2
2
2
A
A
1
8
FRONT
BACK
x1
Photo Resistor
Standard Solderless
Breadboard
a b c d e f g h i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
a b c d e f g h i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Standard Solderless (Color may vary)
Breadboard
a b c d e f g h i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
a b c d e f g h i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
SparkFun RedBoard Flex Sensor
x1
Soft Potentiometer
x1
Servo
x1
Relay
x1
x1
x1
LCD
x1
(IC)
Integrated Circuit
x1
IOREF
RESET
R
E
S
E
T
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
1
0
T
X
R
X
1
3
3.3V
5V
GND
GND
VIN
A0
A1
A2
A3
A4
A5
P
O
W
E
R
A
N
A
L
O
G

I
N
D
I
G
I
T
A
L

(
P
W
M
~
)
O
N
I
S
P
TX
RX
IOREF
RESET
R
E
S
E
T
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
1
0
T
X
R
X
1
3
3.3V
5V
GND
GND
VIN
A0
A1
A2
A3
A4
A5
P
O
W
E
R
A
N
A
L
O
G

I
N
D
I
G
I
T
A
L

(
P
W
M
~
)
O
N
I
S
P
TX
RX
1
2
8
6
9
7
4 3 5
10
// Pins Diagram
SparkFun RedBoard
RFU - This pin is reserved for future use. 11
Power In (Barrel Jack) - Can be used with either a 9V or 12V wall-wart or battery. 1
Power In (USB Port) - Provides power and communicates with your board when plugged into your computer via USB. 2
LED (RX: Receiving) - This shows when the FTDI chip is receiving data bits from the microcontroller. This happens when the microcontroller is
sending data bits back to the computer.
3
LED (TX: Transmitting) - This shows when the FTDI chip is transmitting data bits to the microcontroller. This happens when the
microcontroller is receiving this data from the computer.
4
LED (Pin 13: Troubleshooting) - This LED is incorporated into your sketch to show if your program is running properly. 5
Pins (ARef, Ground, Digital, Rx, Tx) - These various pins can be used for inputs, outputs, power, and ground. // See Diagram Below 6
LED (Indicates RedBoard is ON) - This is a simple power indicator LED. 7
Reset Button - This is a way to manually reset your RedBoard, which makes your code restart. 8
Pins (Analog In, Power In, Ground, Power Out, Reset) - These various pins can be used for inputs, outputs, power, and ground. // See Diagram 10
ICSP Pins (Uploading Code without Bootloader) - This is for "In-Circuit Serial Programming," used if you want to bypass the bootloader. 9
Power Out
Reset
IOREF
Power Out
Ground
Ground
Power In
Analog
Analog
Analog
Analog
Analog
Analog
Ground
ARef
SDA
SCL
Digital
Digital
Digital
Digital
Digital
Digital
Digital
Digital
Digital
Digital
Digital
Digital
TX - Out
RX - In
10
11
6
= PWM/Analog out compatible (i.e. )
The header pins are one of the most important parts for putting our
example circuits together. Take a moment and locate the input/output
ports of your RedBoard.
RFU
a b c d e f g h i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
a b c d e f g h i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
This line divides the board in half, restricting electricity to one half or the other.
1
2
Power:
Each + sign runs power anywhere in the
vertical column.
Ground:
Each - sign runs to ground anywhere in the
vertical column.
Horizontal Rows:
Each of these rows numbered 1-30 are
comprised of ve horizontal sockets.
Components placed in the same row will be
connected in a circuit when power is running.
Vertical Connection (+ Power and - Ground) - Power bus // See Diagram Below 1
Horizontal Connection (a-e & f-j) // See Diagram Below) 2
Hows it all connected?
View of the inside
f g h i a b c d e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
a b c d e f g h i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Breadboard
Above the breadboard
CONNECTED!
LED
Making a Connection:
Inside the breadboard
How It Works:
ASSEMBLE WRITE UPLOAD
Peel stcker o back of
breadboard and stck into place.
Make sure the text on the RedBoard and
breadboard are facing up so you can read them.
a b c d e f g h i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
a b c d e f g h i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Screw the RedBoard down and into place.
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
( P
W
M
~
)
O
N
I S
P
T
X
R
X
Connect the USB cable.
IOREF
RESET
R
E
S
E
T
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
1
0
T
X
R
X
1
3
3.3V
5V
GND
GND
VIN
A0
A1
A2
A3
A4
A5
P
O
W
E
R
A
N
A
L
O
G
IN
D
IG
ITA
L
(P
W
M
~
)
O
N
IS
P
TX
RX
CIRCUIT #1 - Your First Circuit
Your RedBoard runs on 5V. Tis is the power that will be supplied from your computer via USB and
will be the driving force behind any components you use in your circuits. By plugging your RedBoard
into your computer, you are supplying it with just the right voltage it needs to thrive! 5V cant hurt you,
so dont be afraid to touch anything in your circuit. You can also power the RedBoard through the
barrel jack. Te on-board voltage regulator can handle anything from 7 to 15VDC.
IOREF
RESET
R
E
S
E
T
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
1
0
T
X
R
X
1
3
3.3V
5V
GND
GND
VIN
A0
A1
A2
A3
A4
A5
P
O
W
E
R
A
N
A
L
O
G
IN
D
IG
ITA
L
(P
W
M
~
)
O
N
IS
P
TX
RX
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
(
P
W
M
~
)
O
N
I S
P
T
X
R
X
P
A
R
T
S
:
LED
1 X
Wire
3 X
330
Resistor
1 X This secton lists the parts you
will need to complete the circuit.
Circuit 2
LEDs (light-emitting diodes) are small, powerful lights
that are used in many diferent applications. To start of
the SIK, we will work on blinking an LED. Tat's right
- it's as simple as turning a light on and of. It might
not seem like much, but establishing this important
baseline will give you a solid foundation as we work
toward more complex experiments.
Blinking an LED
1
Each circuit begins with a brief descripton
of the what you are putng together and
the expected result.
This is a schematc of your circuit.
This is an illustraton of how the
completed circuit should look. It is not
necessary to use the black holder for the
RedBoard and breadboard, but we
recommend it for the rst tme inventor!
Components like resistors need to have
their legs bent into 90 angles in order to
correctly t the breadboard sockets. You
can also cut the legs shorter to make them
easier to work with on the breadboard.
LED
(Light-Emitting Diode)
Resistor (330 ohm)
(Orange-Orange-Brown)
RedBoard
GND
(Ground)
PIN 13
I
O
R
E
F
R
E
S
E
T
RESET
7
-
1
5
V
S
C
L
S
D
A
A
R
E
F
G
N
D
1
3
1
2
~
1
1
~
1
0
~
987
~
6
~
54
~
3210
TX
RX
13
3
.
3
V
5
V
G
N
D
G
N
D
V
I
N
A
0
A
1
A
2
A
3
A
4
A
5
POWER ANALOG IN
DIGITAL (PWM~)
ON
ISP
T
X
R
X
C
i
r
c
u
i
t

1
:

B
l
i
n
k
i
n
g

a
n

L
E
D
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
L
E
D
:

M
a
k
e

s
u
r
e

t
h
e

s
h
o
r
t

l
e
g
,

m
a
r
k
e
d

w
i
t
h

a
t

s
i
d
e
,

g
o
e
s

i
n
t
o

t
h
e

n
e
g
a
t
v
e

p
o
s
i
t
o
n

(
-
)
.

3
3
0


R
e
s
i
s
t
o
r
:

T
h
e

c
o
l
o
r

b
a
n
d
i
n
g

s
h
o
u
l
d

r
e
a
d

o
r
a
n
g
e
-
o
r
-
a
n
g
e
-
b
r
o
w
n
-
g
o
l
d
.

T
h
e

c
o
m
p
o
-
n
e
n
t

l
e
g
s

c
a
n

g
o

i
n

e
i
t
h
e
r

h
o
l
e
.

J
u
m
p
e
r

W
i
r
e
:

A
l
l

j
u
m
p
e
r

w
i
r
e
s

w
o
r
k

t
h
e

s
a
m
e
.

T
h
e
y

a
r
e

u
s
e
d

t
o

c
o
n
n
e
c
t

t
w
o

p
o
i
n
t
s

t
o
g
e
t
h
e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
.
B
r
e
a
d
b
o
a
r
d
:

T
h
e

w
h
i
t
e

b
a
c
k
g
r
o
u
n
d

r
e
p
r
e
s
e
n
t
s

a

c
o
n
n
e
c
t
o
n

t
o

a

b
r
e
a
d
b
o
a
r
d

s
o
c
k
e
t

s
p
e
c
i

e
d

b
y

a

l
e
t
e
r
-
n
u
m
b
e
r

c
o
o
r
d
i
n
a
t
e

s
u
c
h

a
s

e
2
.

T
h
e
s
e

c
o
o
r
d
i
n
a
t
e
s

a
r
e

m
e
r
e
l
y

s
u
g
g
e
s
t
o
n
s

t
h
a
t

a
l
i
g
n

w
i
t
h

t
h
e

g
r
a
p
h
i
c

i
m
a
g
e
.

R
e
d
B
o
a
r
d
:

T
h
e

r
e
d

b
a
c
k
g
r
o
u
n
d

r
e
p
r
e
s
e
n
t
s

a

c
o
n
n
e
c
t
o
n

t
o

o
n
e

o
f

t
h
e

R
e
d
B
o
a
r
d

h
e
a
d
e
r

p
i
n
s
.
C
o
m
p
o
n
e
n
t
s

l
i
k
e

L
E
D
s

a
r
e

i
n
s
e
r
t
e
d

i
n
t
o

t
h
e

b
r
e
a
d
b
o
a
r
d

s
o
c
k
e
t
s

c
2
(
l
o
n
g

l
e
g
)

c
3
(
s
h
o
r
t

l
e
g
)
.

S
t
e
p
s

h
i
g
h
l
i
g
h
t
e
d

w
i
t
h

a

y
e
l
l
o
w

w
a
r
n
i
n
g

t
r
i
a
n
g
l
e

r
e
p
r
e
s
e
n
t

a

p
o
l
a
r
i
z
e
d

c
o
m
p
o
n
e
n
t
.

P
a
y

s
p
e
c
i
a
l

a
t
e
n
t
o
n

t
o

t
h
e

c
o
m
p
o
n
e
n
t

s

m
a
r
k
i
n
g
s

i
n
d
i
c
a
t
n
g

h
o
w

t
o

p
l
a
c
e

i
t

o
n

t
h
e

b
r
e
a
d
b
o
a
r
d
.
Open Up the Arduino IDE software on your computer. Coding in the Arduino
language will control your circuit. Open the code for Circuit 1 by accessing the SIK
Guide Code you downloaded and placed into your Examples folder earlier.
Open Your First Sketch:
File Edit Sketch Tools Help
1.Basics
2.Digital
3.Analog
4.Communication
5.Control
6.Sensors
7.Displays
8.Strings
ArduinoISP
SIK Guide Code
EEPROM
Ethernet
Firmata
Liquid Crystal
SD
Servo
SoftwareSerial
SPI
Stepper
Wire
Page Setup
Print
New
Open...
Sketchbook
Examples
Close
Save
Save As...
Upload
Upload Using Progammer
Circuit #1
Circuit #2
Circuit #3
Circuit #4
Circuit #5
Circuit #6
Circuit #7
Circuit #8
Circuit #9
Circuit #10
Circuit #11
Circuit #12
Circuit #13
Circuit #14
Circuit #15
Circuit #1
/*
Blink
Turns on an LED on for one second,
then off for one second, repeatedly.

This example code is in the public domain.
*/
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
}
// Circuit #1
Verify
Upload
// The result of a completed circuit with correct code after veried and uploaded.
Tis compiles your code. Te IDE changes it from text into instructions the computer
can understand.
Tis sends the instructions via the USB cable to the computer chip on the RedBoard. Te
RedBoard will then begin running your code automatically.
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G

I N
D
I G
I T
A
L

(
P
W
M
~
)
O
N
I S
P
T
X
R
X
Circuit 2
Arduino Code:
1
Troubleshooting:
LED Not Lighting Up?
LEDs will only work in one direction. Try taking it out and
twisting it 180 degrees (no need to worry, installing it
backward does no permanent harm).
Program Not Uploading
Tis happens sometimes, the most likely cause is a confused
serial port, you can change this in tools>serial port>
Still No Success?
A broken circuit is no fun, send us an e-mail and we will get
back to you as soon as we can: techsupport@sparkfun.com
You should see your LED blink on and of. If
it isn't, make sure you have assembled the
circuit correctly and verifed and uploaded the
code to your board or see the troubleshooting
tips below.
Before you can use one of the RedBoard's pins, you need to tell the
RedBoard whether it is an INPUT or OUTPUT. We use a built-in
"function" called pinMode() to do this.
When you're using a pin as an OUTPUT, you can command it to be
HIGH (output 5 volts), or LOW (output 0 volts).
digitalWrite(13, HIGH);
pinMode(13, OUTPUT);
Code to Note:
Real World Application:
Almost all modern fat screen televisions and monitors
have LED indicator lights to show they are on or of.
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 1
What you Should See:
This is where you will nd the
Arduino code for each circuit.
Remember to Verify and
Upload your code.
See if your circuit is complete
and working in this secton.
Begin to understand how the
Arduino code works. See below.
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
( P
W
M
~
)
O
N
I S
P
T
X
R
X
This is a secton dedicated to the most
common mistakes made while assembling
the circuit.
Here you will nd examples of the circuit
you just completed in the real world.
Many of the theories in these circuits are
used in things you use everyday!
Circuit 2
P
A
R
T
S
:
Wire
19 X
CIRCUIT #5
IC
1 X
330
Resistor
8 X
LED
8 X
Circuit 2
In this circuit youll work with a potentiometer.
A potentiometer is also known as a variable resistor.
When its connected with 5 volts across its two outer
pins, the middle pin outputs a voltage between 0 and
5, depending on the position of the knob on the
potentiometer. A potentiometer is a perfect
demonstration of a variable voltage divider circuit.
Te voltage is divided proportionate to the resistance
between the middle pin and the ground pin. In this
circuit, youll learn how to use a potentiometer to
control the brightness of an LED.
Potentiometer
P
A
R
T
S
:
Wire
6 X
CIRCUIT #2
2
LED
1 X
330
Resistor
1 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t
s
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
(
P
W
M
~
)
O
N
I S
P
T
X
R
X
Most traditional volume knobs employ a potentiometer.
Circuit 2
Arduino Code:
2
Troubleshooting:
Sporadically Working
Tis is most likely due to a slightly dodgy connection
with the potentiometer's pins. Tis can usually be
conquered by holding the potentiometer down.
Not Working
Make sure you havent accidentally connected the
wiper, the resistive element in the potentiometer, to
digital pin 0 rather than analog pin 0. (the row of pins
beneath the power pins).
LED Not Lighting Up?
LEDs will only work in one direction. Try taking it out and
twisting it 180 degrees (no need to worry, installing it
backward does no permanent harm).
You should see the LED blink faster
or slower in accordance with your
potentiometer. If it isn't working,
make sure you have assembled the
circuit correctly and verifed and
uploaded the code to your board or
see the troubleshooting tips below.
A variable is a stored value youve given a name to. You must introduce,
or "declare" variables before you use them; here we're declaring a variable
called sensorValue, of type "int" (integer). Don't forget that variable names
are case-sensitive!
int sensorValue;
Code to Note:
Real World Application:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 2
What you Should See:
Te Arduino is very very fast, capable of running thousands of lines of code
each second. To slow it down so that we can see what it's doing, we'll often
insert delays into the code. delay() counts in milliseconds; there are 1000 ms
in one second.
delay(sensorValue);
We use the analogRead() function to read the value on an analog
pin. analogRead() takes one parameter, the analog pin you want
to use ("sensorPin"), and returns a number ("sensorValue")
between 0 (0 volts) and 1023 (5 volts).
sensorValue = analogRead(sensorPin);
Circuit 2
P
A
R
T
S
:
p.10
IC
1 X
330
Resistor
8 X
LED
8 X
You know whats even more fun than a blinking
LED? Changing colors with one LED. RGB, or
red-green-blue, LEDs have three diferent color-emit-
ting diodes that can be combined to create all sorts of
colors. In this circuit, youll learn how to use an RGB
LED to create unique color combinations.
Depending on how bright each diode is, nearly any
color is possible!
RGB LED
P
A
R
T
S
:
CIRCUIT #3
3
p.28
Potentiometer
1 X
Transistor
P2N2222AG
1 X
Wire
6 X
330
Resistor
3 X
LED
1 X
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
(
P
W
M
~
)
O
N
I S
P
T
X
R
X
red
common
green
blue
GND
(Ground)
R
E
D
G
R
E
E
N
B
L
U
E
RedBoard
PIN 11
PIN 10
PIN 9
Resistors (330 ohm)
(Orange-Orange-Brown)
LED
(Light-Emitting Diode)
I
O
R
E
F
R
E
S
E
T
RESET
7
-
1
5
V
S
C
L
S
D
A
A
R
E
F
G
N
D
1
3
1
2
~
1
1
~
1
0
~
987
~
6
~
54
~
3210
TX
RX
13
3
.
3
V
5
V
G
N
D
G
N
D
V
I
N
A
0
A
1
A
2
A
3
A
4
A
5
POWER ANALOG IN
DIGITAL (PWM~)
ON
ISP
T
X
R
X
C
i
r
c
u
i
t

3
:

R
G
B

L
E
D
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
*

T
h
e

l
o
n
g
e
s
t

l
e
a
d

i
s

t
h
e

c
o
m
m
o
n
(
g
n
d
)
.
C
o
m
p
o
n
e
n
t
:
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r
d

w
i
t
h


n
e
x
t

t
o

t
h
e
m

a
r
e

P
W
M
/
A
n
a
l
o
g

o
u
t

c
o
m
p
a
t
i
b
l
e
.
T
e

R
e
d
B
o
a
r
d

i
s

s
o

f
a
s
t

t
h
a
t

i
t

c
a
n

b
l
i
n
k

a

p
i
n

o
n

a
n
d

o
f

a
l
m
o
s
t

1
0
0
0

t
i
m
e
s

p
e
r

s
e
c
o
n
d
.

P
W
M

g
o
e
s

o
n
e

s
t
e
p

f
u
r
t
h
e
r

b
y

v
a
r
y
i
n
g

t
h
e

a
m
o
u
n
t

o
f

t
i
m
e

t
h
a
t

t
h
e

b
l
i
n
k
i
n
g

p
i
n

s
p
e
n
d
s

H
I
G
H

v
s
.

t
h
e

t
i
m
e

i
t

s
p
e
n
d
s

L
O
W
.

I
f

i
t

s
p
e
n
d
s

m
o
s
t

o
f

i
t
s

t
i
m
e

H
I
G
H
,

a

L
E
D

c
o
n
n
e
c
t
e
d

t
o

t
h
a
t

p
i
n

w
i
l
l

a
p
p
e
a
r

b
r
i
g
h
t
.

I
f

i
t

s
p
e
n
d
s

m
o
s
t

o
f

i
t
s

t
i
m
e

L
O
W
,

t
h
e

L
E
D

w
i
l
l

l
o
o
k

d
i
m
.

B
e
c
a
u
s
e

t
h
e

p
i
n

i
s

b
l
i
n
k
i
n
g

m
u
c
h

f
a
s
t
e
r

t
h
a
n

y
o
u
r

e
y
e

c
a
n

d
e
t
e
c
t
,

t
h
e

R
e
d
B
o
a
r
d

c
r
e
a
t
e
s

t
h
e

i
l
l
u
s
i
o
n

o
f

a

"
t
r
u
e
"

a
n
a
l
o
g

o
u
t
p
u
t
.
T
h
e

s
h
o
c
k
i
n
g

t
r
u
t
h

b
e
h
i
n
d

a
n
a
l
o
g
W
r
i
t
e
(
)
:
9
0
% 9
0
%
5
0
%
5
0
%
0
.
5
V
2
.
5
V
4
.
5
V
L
O
W

(
0

v
o
l
t
s
)
H
I
G
H

(
5

v
o
l
t
s
)
L
O
W

(
0

v
o
l
t
s
)
H
I
G
H

(
5

v
o
l
t
s
)
L
O
W

(
0

v
o
l
t
s
)
H
I
G
H

(
5

v
o
l
t
s
)
1
0
%
1
0
%
a
4
a
5
a
6
a
7
Many electronics such as
videogame consoles use RGB
LEDs to have the versatility
to show diferent colors in
the same area. Often times
the difent colors represent
diferent states of working
condition.
Circuit 2
Arduino Code:
3
Troubleshooting:
LED Remains Dark or Shows Incorrect Color
With the four pins of the LED so close together, its
sometimes easy to misplace one. Double check each
pin is where it should be.
Seeing Red
Te red diode within the RGB LED may be a bit brighter
than the other two. To make your colors more balanced,
use a higher Ohm resistor. Or adjust in code.
analogWrite(RED_PIN, redIntensity);

to
analogWrite(RED_PIN, redIntensity/3);
You should see your LED turn on,
but this time in new, crazy colors! If it
isn't, make sure you have assembled
the circuit correctly and verifed and
uploaded the code to your board or
see the troubleshooting tips below.
Code to Note:
Real World Application:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 3
What you Should See:
A for() loop is used to step a number across a range, and repeatedly runs
code within the brackets {}. Here the variable "x" starts a 0, ends at 767,
and increases by one each time ("x++").
for (x = 0; x < 768; x++)
{}
Te RedBoard is very very fast, capable of running thousands of lines of
code each second. To slow it down so that we can see what it's doing,
we'll often insert delays into the code. delay() counts in milliseconds;
there are 1000 ms in one second.
delay(sensorValue);
"If / else" statements are used to make choices in your programs. Te statement
within the parenthesis () is evaluated; if it's true, the code within the frst brackets {}
will run. If it's not true, the code within the second brackets {} will run.
if (x <= 255)
{}
else
{}
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G

I
N
D
I
G
I
T
A
L

(
P
W
M
~
)
O
N
I
S
P
T
X
R
X
So you have gotten one LED to blink on and of
fantastic! Now it's time to up the stakes a little bit by
connecting EIGHT LEDS AT ONCE. We'll also give
our RedBoard a little test by creating various lighting
sequences. Tis circuit is a great setup to start practicing
writing your own programs and getting a feel for the
way RedBoard works.
Along with controlling the LEDs, youll learn about a
couple programming tricks that keep your code neat
and tidy:
for() loops - used when you want to run a piece of
code several times
arrays[ ] - used to make managing variables easier by
grouping them together
Multiple LEDs
p.32
P
A
R
T
S
:
LED
8 X
Wire
10 X
330
Resistor
8 X
CIRCUIT #4
4
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
(
P
W
M
~
)
O
N
I S
P
T
X
R
X
Resistors (330 ohm)
(Orange-Orange-Brown)
LEDs
(Light-Emitting Diodes)
RedBoard
PIN 2
PIN 3
PIN 4
PIN 5
GND (Ground)
Resistors (330 ohm)
(Orange-Orange-Brown)
LEDs
(Light-Emitting Diodes)
RedBoard
PIN 6
PIN 7
PIN 8
PIN 9
GND (Ground)
I
O
R
E
F
R
E
S
E
T
RESET
7
-
1
5
V
S
C
L
S
D
A
A
R
E
F
G
N
D
1
3
1
2
~
1
1
~
1
0
~
987
~
6
~
54
~
3210
TX
RX
13
3
.
3
V
5
V
G
N
D
G
N
D
V
I
N
A
0
A
1
A
2
A
3
A
4
A
5
POWER ANALOG IN
DIGITAL (PWM~)
ON
ISP
T
X
R
X
C
i
r
c
u
i
t

4
:

M
u
l
t
i
p
l
e

L
E
D
s
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
a
b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
2
3
+
Circuit 2
Arduino Code:
4
Troubleshooting:
Some LEDs Fail to Light
It is easy to insert an LED backwards. Check the LEDs
that aren't working and ensure they the right way
around.
Operating out of sequence
With eight wires it's easy to cross a couple. Double check
that the frst LED is plugged into pin 2 and each pin
there after.
Starting Afresh
Its easy to accidentally misplace a wire without noticing.
Pulling everything out and starting with a fresh slate is
often easier than trying to track down the problem.
Tis is similar to circuit number one, but
instead of one LED, you should see all the
LEDs blink. If they aren't, make sure you
have assembled the circuit correctly and
verifed and uploaded the code to your board
or see the troubleshooting tips below.
Code to Note:
Real World Application:
Scrolling marquee displays are generally used to spread
short segments of important information. Tey are built
out of many LEDs.
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 4
What you Should See:
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
( P
W
M
~
)
O
N
I S
P
T
X
R
X
When you have to manage a lot of variables, an "array" is
a handy way to group them together. Here we're creating
an array of integers, called ledPins, with eight elements.
int ledPins[] = {2,3,4,5,6,7,8,9};
Computers like to do the same things each time they run. But sometimes
you want to do things randomly, such as simulating the roll of a dice. Te
random() function is a great way to do this.
See http://arduino.cc/en/reference/random for more information.
index = random(8);
You refer to the elements in an array by their position.
Te frst element is at position 0, the second is at position
1, etc. You refer to an element using "ledPins[x]" where x
is the position. Here we're making digital pin 2 HIGH,
since the array element at position 0 is "2".
digitalWrite(ledPins[0], HIGH);
Circuit 2
P
A
R
T
S
:
Wire
19 X
IC
1 X
330
Resistor
8 X
LED
8 X
Circuit 2
Up until now, weve focused solely on outputs. Now
were going to go to the other end of spectrum and
play around with inputs. In this circuit, well be
looking at one of the most common and simple
inputs a push button. Te way a push button works
with RedBoard is that when the button is pushed, the
voltage goes LOW. Te RedBoard reads this and
reacts accordingly. In this circuit, you will also use a
pull-up resistor, which keeps the voltage HIGH when
you're not pressing the button.
Push Buttons
P
A
R
T
S
:
Wire
7 X
CIRCUIT #5
5
Push Button
2 X
LED
1 X
330
Resistor
1 X
10K
Resistor
2 X
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
(
P
W
M
~
)
O
N
I S
P
T
X
R
X
p.10 p.36
Resistors (330 ohm)
(Orange-Orange-Brown)
GND
(Ground)
Resistors (10K ohm)
(Brown-Black-Orange)
LED
(Light-Emitting Diode)
RedBoard
Buttons
PIN 13
PIN 2 PIN 3
5 volt
I
O
R
E
F
R
E
S
E
T
RESET
7
-
1
5
V
S
C
L
S
D
A
A
R
E
F
G
N
D
1
3
1
2
~
1
1
~
1
0
~
987
~
6
~
54
~
3210
TX
RX
13
3
.
3
V
5
V
G
N
D
G
N
D
V
I
N
A
0
A
1
A
2
A
3
A
4
A
5
POWER ANALOG IN
DIGITAL (PWM~)
ON
ISP
T
X
R
X
C
i
r
c
u
i
t

5
:

P
u
s
h

B
u
t
t
o
n
s
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
C
o
m
p
o
n
e
n
t
:
I
m
a
g
e

R
e
f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
t
a
t
e
m
e
n
t
s
.

T
e
y

i
n
c
l
u
d
e
:
Y
o
u

c
a
n

c
o
m
b
i
n
e

t
h
e
s
e

f
u
n
c
t
i
o
n
s

t
o

b
u
i
l
d

c
o
m
p
l
e
x

i
f
(
)

s
t
a
t
e
m
e
n
t
s
.

F
o
r

e
x
a
m
p
l
e
:
i
f

(
(
m
o
d
e

=
=

h
e
a
t
)

&
&

(
(
t
e
m
p
e
r
a
t
u
r
e

<

t
h
r
e
s
h
o
l
d
)

|
|

(
o
v
e
r
r
i
d
e

=
=

t
r
u
e
)
)
)
{d
i
g
i
t
a
l
W
r
i
t
e
(
H
E
A
T
E
R
,

H
I
G
H
)
;
}.
.
.
w
i
l
l

t
u
r
n

o
n

a

h
e
a
t
e
r

i
f

y
o
u
'
r
e

i
n

h
e
a
t
i
n
g

m
o
d
e

A
N
D

t
h
e

t
e
m
p
e
r
a
t
u
r
e

i
s

l
o
w
,

O
R

i
f

y
o
u

t
u
r
n

o
n

a

m
a
n
u
a
l

o
v
e
r
r
i
d
e
.

U
s
i
n
g

t
h
e
s
e

l
o
g
i
c

o
p
e
r
a
t
o
r
s
,

y
o
u

c
a
n

p
r
o
g
r
a
m

y
o
u
r

R
e
d
B
o
a
r
d

t
o

m
a
k
e

i
n
t
e
l
l
i
g
e
n
t

d
e
c
i
s
i
o
n
s

a
n
d

t
a
k
e

c
o
n
t
r
o
l

o
f

t
h
e

w
o
r
l
d

a
r
o
u
n
d

i
t
!
H
o
w

t
o

u
s
e

l
o
g
i
c

l
i
k
e

a

V
u
l
c
a
n
:
=
=
E
Q
U
I
V
A
L
E
N
C
E
A

=
=

B

i
s

t
r
u
e

i
f

A

a
n
d

B

a
r
e

t
h
e

S
A
M
E
.
!
=
D
I
F
F
E
R
E
N
C
E
A

!
=

B

i
s

t
r
u
e

i
f

A

a
n
d

B

a
r
e

N
O
T

T
H
E

S
A
M
E
.
&
&
A
N
D
A

&
&

B

i
s

t
r
u
e

i
f

B
O
T
H

A

a
n
d

B

a
r
e

T
R
U
E
.
|
|
O
R
A

|
|

B

i
s

t
r
u
e

i
f

A

o
r

B

o
r

B
O
T
H

a
r
e

T
R
U
E
.
!
N
O
T
!
A

i
s

T
R
U
E

i
f

A

i
s

F
A
L
S
E
.

!
A

i
s

F
A
L
S
E

i
f

A

i
s

T
R
U
E
.
J
u
m
p
e
r

W
i
r
e
G
N
D
J
u
m
p
e
r

W
i
r
e
5
V
+
Te buttons we used here are similar to the buttons in
most video game controllers.
Circuit 2
Arduino Code:
5
Troubleshooting:
Light Not Turning On
Te pushbutton is square, and because of this it is easy to
put it in the wrong way. Give it a 90 degree twist and see
if it starts working.
Underwhelmed
No worries, these circuits are all super stripped down to
make playing with the components easy, but once you
throw them together the sky is the limit.
You should see the LED turn on
if you press either button, and of
if you press both buttons. (See the
code to fnd out why!) If it isn't
working, make sure you have
assembled the circuit correctly
and verifed and uploaded the
code to your board or see the
troubleshooting tips below.
Code to Note:
Real World Application:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 5
What You Should See:
Te digital pins can be used as inputs as well as outputs.
Before you do either, you need to tell the RedBoard
which direction you're going.
pinMode(button2Pin, INPUT);
Because we've connected the button to GND, it will read LOW when
it's being pressed. Here we're using the "equivalence" operator ("==")
to see if the button is being pressed.
if (button1State == LOW)
To read a digital input, you use the digitalRead()
function. It will return HIGH if there's 5V present at the
pin, or LOW if there's 0V present at the pin.
button1State = digitalRead(button1Pin);
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
( P
W
M
~
)
O
N
I S
P
T
X
R
X
Circuit 2
So youve already played with a potentiometer, which
varies resistance based on the twisting of a knob. In
this circuit, youll be using a photo resistor, which
changes resistance based on how much light the
sensor receives. Since the RedBoard cant directly
interpret resistance (rather, it reads voltage), we use a
voltage divider to use our photo resistor. Tis voltage
divider will output a high voltage when it is getting a
lot of light and a low voltage when it is not.
Photo Resistor
P
A
R
T
S
:
Wire
6 X
CIRCUIT #6
6
LED
1 X
330
Resistor
1 X
Photo Resistor
1 X
10K
Resistor
1 X
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
(
P
W
M
~
)
O
N
I S
P
T
X
R
X
p.40
PIN 9
PIN A0
Resistor (330 ohm)
(Orange-Orange-Brown)
GND
(Ground)
Resistor (10K ohm)
(Brown-Black-Orange)
LED
(Light-Emitting Diode)
Photocell
(Light Sensitive Resistor)
RedBoard
5 volt
I
O
R
E
F
R
E
S
E
T
RESET
7
-
1
5
V
S
C
L
S
D
A
A
R
E
F
G
N
D
1
3
1
2
~
1
1
~
1
0
~
987
~
6
~
54
~
3210
TX
RX
13
3
.
3
V
5
V
G
N
D
G
N
D
V
I
N
A
0
A
1
A
2
A
3
A
4
A
5
POWER ANALOG IN
DIGITAL (PWM~)
ON
ISP
T
X
R
X
C
i
r
c
u
i
t

6

:

P
h
o
t
o

R
e
s
i
s
t
o
r
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
C
o
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v
i
d
e
r

c
o
n
s
i
s
t
s

o
f

t
w
o

r
e
s
i
s
t
o
r
s
.

T
e

"
t
o
p
"

r
e
s
i
s
t
o
r

i
s

t
h
e

s
e
n
s
o
r

y
o
u
'
l
l

b
e

u
s
i
n
g
.

T
e

"
b
o
t
t
o
m
"

o
n
e

i
s

a

n
o
r
m
a
l
,

f
x
e
d

r
e
s
i
s
t
o
r
.

W
h
e
n

y
o
u

c
o
n
n
e
c
t

t
h
e

t
o
p

r
e
s
i
s
t
o
r

t
o

5

v
o
l
t
s
,

a
n
d

t
h
e

b
o
t
t
o
m

r
e
s
i
s
t
o
r

t
o

g
r
o
u
n
d
.

T
e

v
o
l
t
a
g
e

a
t

t
h
e

m
i
d
d
l
e

w
i
l
l

b
e

p
r
o
p
o
r
t
i
o
n
a
l

t
o

t
h
e

b
o
t
t
o
m

r
e
s
i
s
t
o
r

r
e
l
a
t
i
v
e

t
o

t
h
e

t
o
t
a
l

r
e
s
i
s
t
a
n
c
e

(
t
o
p

r
e
s
i
s
t
o
r

+

b
o
t
t
o
m

r
e
s
i
s
t
o
r
)
.

W
h
e
n

o
n
e

o
f

t
h
e

r
e
s
i
s
t
o
r
s

c
h
a
n
g
e
s

(
a
s

i
t

w
i
l
l

w
h
e
n

y
o
u
r

s
e
n
s
o
r

s
e
n
s
e
s

t
h
i
n
g
s
)
,

t
h
e

o
u
t
p
u
t

v
o
l
t
a
g
e

w
i
l
l

c
h
a
n
g
e

a
s

w
e
l
l
!
A
l
t
h
o
u
g
h

t
h
e

s
e
n
s
o
r
'
s

r
e
s
i
s
t
a
n
c
e

w
i
l
l

v
a
r
y
,

t
h
e

r
e
s
i
s
t
i
v
e

s
e
n
s
o
r
s

(
f
e
x

s
e
n
s
o
r

l
i
g
h
t

s
e
n
s
o
r
,

s
o
f
t
p
o
t
,

a
n
d

t
r
i
m
p
o
t
)

i
n

t
h
e

S
I
K

a
r
e

a
r
o
u
n
d

1
0
K

o
h
m
s
.

W
e

u
s
u
a
l
l
y

w
a
n
t

t
h
e

f
x
e
d

r
e
s
i
s
t
o
r

t
o

b
e

c
l
o
s
e

t
o

t
h
i
s

v
a
l
u
e
,

s
o

u
s
i
n
g

a

1
0
K

r
e
s
i
s
t
o
r

i
s

a

g
r
e
a
t

c
h
o
i
c
e

f
o
r

t
h
e

f
x
e
d

"
b
o
t
t
o
m
"

r
e
s
i
s
t
o
r
.

P
l
e
a
s
e

n
o
t
e

t
h
e

f
x
e
d

r
e
s
i
s
t
o
r

i
s
n
'
t

n
e
c
e
s
s
a
r
i
l
y

t
h
e

b
o
t
t
o
m

r
e
s
i
s
t
o
r
.

W
e

d
o

t
h
a
t

w
i
t
h

t
h
e

p
h
o
t
o
d
i
o
d
e

o
n
l
y

s
o

t
h
a
t

m
o
r
e

l
i
g
h
t

=

m
o
r
e

v
o
l
t
a
g
e
,

b
u
t

i
t

c
o
u
l
d

b
e

f
i
p
p
e
d

a
n
d

w
e
'
d

g
e
t

t
h
e

o
p
p
o
s
i
t
e

r
e
s
p
o
n
s
e
.
M
e
a
s
u
r
i
n
g

r
e
s
i
s
t
i
v
e

s
e
n
s
o
r
s
:
P
I
N

3
5

v
o
l
t
s
G
N
D
(
g
r
o
u
n
d
)

(
-
)
P
i
n

A
0
A street lamp uses a light sensor to detect when to turn
the lights on at night.
Circuit 2
Arduino Code:
6
Troubleshooting:
LED Remains Dark
Tis is a mistake we continue to make time and time
again, if only they could make an LED that worked both
ways. Pull it up and give it a twist.
It Isn't Responding to Changes in Light
Given that the spacing of the wires on the photo-resistor
is not standard, it is easy to misplace it. Double check its
in the right place.
Still Not Quite Working
You may be in a room which is either too bright or dark.
Try turning the lights on or of to see if this helps. Or if
you have a fashlight near by give that a try.
You should see the LED grow brighter
or dimmer in accordance with how
much light your photoresistor is
reading. If it isn't working, make sure
you have assembled the circuit
correctly and verifed and uploaded
the code to your board or see the
troubleshooting tips below.
Code to Note:
Real World Application:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 6
What You Should See:
When we read an analog signal using analogRead(), it will be
a number from 0 to 1023. But when we want to drive a
PWM pin using analogWrite(), it wants a number from 0 to
255. We can "squeeze" the larger range into the smaller range
using the map() function.
lightLevel = map(lightLevel, 0, 1023, 0, 255);
Because map() could still return numbers outside the "to"
range, we'll also use a function called constrain() that will
"clip" numbers into a range. If the number is outside the
range, it will make it the largest or smallest number. If it is
within the range, it will stay the same.
lightLevel = constrain(lightLevel, 0, 255);
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
( P
W
M
~
)
O
N
I S
P
T
X
R
X
See http://arduino.cc/en/reference/map for more info.
See http://arduino.cc/en/reference/constrain for more info.
Parameters
map(value, fromLow, fromHigh, toLow, toHigh)
Parameters
constrain(x, a, b)
x: the number to constrain, all data types
a: the lower end of the range, all data types
b: the upper end of the range, all data types
value: the number to map
fromLow: the lower bound of the value's current range
fromHigh: the upper bound of the value's current range
toLow: the lower bound of the value's target range
toHigh: the upper bound of the value's target range
Circuit 2
A temperature sensor is exactly what it sounds like a
sensor used to measure ambient temperature. Tis
particular sensor has three pins a positive, a ground,
and a signal. Tis is a linear temperature sensor. A
change in temperature of one degree centigrade is equal
to a change of 10 millivolts at the sensor output. Te
TMP36 sensor has a nominal 750 mV at 25C (about
room temperature). In this circuit, youll learn how to
integrate the temperature sensor with your RedBoard,
and use the Arduino IDEs serial monitor to display the
temperature.
Temperature Sensor
CIRCUIT #7
7
p.44
GND
(Ground)
RedBoard
TMP36
(Precision Temperature Sensor)
5 volt
GND
3
VCC
1
VOUT
2
PIN A0
P
A
R
T
S
:
Wire
5 X
Temp. Sensor
1 X
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
(
P
W
M
~
)
O
N
I S
P
T
X
R
X
FRONT
BACK
When youre building the circuit be careful not
to mix up the transistor and the temperature
sensor, theyre almost identical. Look for
TMP on the body of the temperature sensor.
SIGNAL
+V
GND
SIGNAL
GND
+V
I
O
R
E
F
R
E
S
E
T
RESET
7
-
1
5
V
S
C
L
S
D
A
A
R
E
F
G
N
D
1
3
1
2
~
1
1
~
1
0
~
987
~
6
~
54
~
3210
TX
RX
13
3
.
3
V
5
V
G
N
D
G
N
D
V
I
N
A
0
A
1
A
2
A
3
A
4
A
5
POWER ANALOG IN
DIGITAL (PWM~)
ON
ISP
T
X
R
X
C
i
r
c
u
i
t

7
:

T
e
m
p
e
r
a
t
u
r
e

S
e
n
s
o
r
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
T
e
m
p
e
r
a
t
u
r
e

S
e
n
s
o
r
f
5
f
7
f
6
C
o
m
p
o
n
e
n
t
:
I
m
a
g
e

R
e
f
e
r
e
n
c
e
:
j
5
J
u
m
p
e
r

W
i
r
e
j
7
J
u
m
p
e
r

W
i
r
e
J
u
m
p
e
r

W
i
r
e
G
N
D
J
u
m
p
e
r

W
i
r
e
5
V
5
V
+
J
u
m
p
e
r

W
i
r
e
A
0
j
6
+
T
i
s

c
i
r
c
u
i
t

u
s
e
s

t
h
e

A
r
d
u
i
n
o

I
D
E
'
s

s
e
r
i
a
l

m
o
n
i
t
o
r
.

T
o

o
p
e
n

t
h
i
s
,

f
r
s
t

u
p
l
o
a
d

t
h
e

p
r
o
g
r
a
m

t
h
e
n

c
l
i
c
k

t
h
e

b
u
t
t
o
n

w
h
i
c
h

l
o
o
k
s

l
i
k
e

a

m
a
g
n
i
f
y
i
n
g

g
l
a
s
s

i
n

a

s
q
u
a
r
e
.

I
n

o
r
d
e
r

f
o
r

t
h
e

s
e
r
i
a
l

m
o
n
i
t
o
r

t
o

o
p
e
r
a
t
e

c
o
r
r
e
c
t
l
y

i
t

m
u
s
t

b
e

s
e
t

t
o

t
h
e

s
a
m
e

b
a
u
d

r
a
t
e

(
s
p
e
e
d

i
n

b
i
t
s

p
e
r

s
e
c
o
n
d
)

a
s

t
h
e

c
o
d
e

y
o
u
'
r
e

r
u
n
n
i
n
g
.

T
i
s

c
o
d
e

r
u
n
s

a
t

9
6
0
0

b
a
u
d
;

i
f

t
h
e

b
a
u
d

r
a
t
e

s
e
t
t
i
n
g

i
s

n
o
t

9
6
0
0
,

c
h
a
n
g
e

i
t

t
o

9
6
0
0
.
O
p
e
n
i
n
g

y
o
u
r

s
e
r
i
a
l

m
o
n
i
t
o
r
:
1
2
3
+
V
S
I
G
N
A
L
G
N
D
-
+
V
O
U
T
Building climate control systems use a temperature sensor
to monitor and maintain their settings.
Circuit 2
Arduino Code:
7
Troubleshooting:
Nothing Seems to Happen
Tis program has no outward indication it is working. To
see the results you must open the Arduino IDE's serial
monitor (instructions on previous page).
Gibberish is Displayed
Tis happens because the serial monitor is receiving data at
a diferent speed than expected. To fx this, click the
pull-down box that reads "*** baud" and change it to
"9600 baud".
Temperature Value is Unchanging
Try pinching the sensor with your fngers to heat it up or
pressing a bag of ice against it to cool it down.
You should be able to read the
temperature your temperature
sensor is detecting on the serial
monitor in the Arduino IDE. If it
isn't working, make sure you have
assembled the circuit correctly and
verifed and uploaded the code to
your board or see the troubleshoot-
ing tips below.
Code to Note:
Real World Application:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 7
What You Should See:
Before using the serial monitor, you must call Serial.begin() to
initialize it. 9600 is the "baud rate", or communications speed. When
two devices are communicating with each other, both must be set to
the same speed.
Serial.begin(9600);
Serial.print() will print everything on the same line. Serial.println() will
move to the next line. By using both of these commands together, you
can create easy-to-read printouts of text and data.
Serial.println(degreesF);
Te Serial.print() command is very smart. It can print out almost
anything you can throw at it, including variables of all types,
quoted text (AKA "strings"), etc.
See http://arduino.cc/en/serial/print for more info.
Serial.print(degreesC);
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
( P
W
M
~
)
O
N
I S
P
T
X
R
X
voltage: 0.73 deg C: 23.24 deg F: 73.84
voltage: 0.73 deg C: 23.24 deg F: 73.84
voltage: 0.73 deg C: 23.24 deg F: 73.84
voltage: 0.73 deg C: 22.75 deg F: 72.96
voltage: 0.73 deg C: 23.24 deg F: 73.84
voltage: 0.73 deg C: 23.24 deg F: 73.84
voltage: 0.73 deg C: 23.24 deg F: 73.84
voltage: 0.73 deg C: 22.75 deg F: 72.96
voltage: 0.73 deg C: 23.24 deg F: 73.84
voltage: 0.73 deg C: 22.75 deg F: 72.96
voltage: 0.73 deg C: 22.75 deg F: 72.96
voltage: 0.73 deg C: 23.24 deg F: 73.84
voltage: 0.73 deg C: 22.75 deg F: 72.96
voltage: 0.73 deg C: 23.24 deg F: 73.84
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
(
P
W
M
~
)
O
N
I S
P
T
X
R
X
Circuit 2
Servos are ideal for embedded electronics applications
because they do one thing very well that motors cannot
they can move to a position accurately. By varying the
pulse width of the output voltage to a servo, you can move
a servo to a specifc position. For example, a pulse of 1.5
milliseconds will move the servo 90 degrees. In this circuit,
youll learn how to use PWM (pulse width modulation)
to control and rotate a servo.
A Single Servo
P
A
R
T
S
:
Wire
8 X
CIRCUIT #8
8
p.48
Servo
1 X
RedBoard
No junction dot means no connection
GND
SIG
V+
W
R
B
5 volt
GND
(Ground)
PIN 9
I
O
R
E
F
R
E
S
E
T
RESET
7
-
1
5
V
S
C
L
S
D
A
A
R
E
F
G
N
D
1
3
1
2
~
1
1
~
1
0
~
987
~
6
~
54
~
3210
TX
RX
13
3
.
3
V
5
V
G
N
D
G
N
D
V
I
N
A
0
A
1
A
2
A
3
A
4
A
5
POWER ANALOG IN
DIGITAL (PWM~)
ON
ISP
T
X
R
X
C
i
r
c
u
i
t

8
:

A

S
i
n
g
l
e

S
e
r
v
o
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
C
o
m
p
o
n
e
n
t
:
I
m
a
g
e

R
e
f
e
r
e
n
c
e
:
S
e
r
v
o
e
5
e
7
e
6
J
u
m
p
e
r

W
i
r
e
J
u
m
p
e
r

W
i
r
e
J
u
m
p
e
r

W
i
r
e
e
6
e
7
e
5
5
V
J
u
m
p
e
r

W
i
r
e
P
i
n

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
d

s
h
a
r
i
n
g

i
t

w
i
t
h

t
h
e

w
o
r
l
d
!
T
o

u
s
e

a

l
i
b
r
a
r
y

i
n

a

s
k
e
t
c
h
,

s
e
l
e
c
t

i
t

f
r
o
m

S
k
e
t
c
h

>

I
m
p
o
r
t

L
i
b
r
a
r
y
.
A
f
t
e
r

i
m
p
o
r
t
i
n
g

t
h
e

l
i
b
r
a
r
y

i
n
t
o

y
o
u
r

c
o
d
e
,

y
o
u

w
i
l
l

h
a
v
e

a
c
c
e
s
s

t
o

a

n
u
m
b
e
r

o
f

p
r
e
-
w
r
i
t
t
e
n

c
o
m
m
a
n
d
s

a
n
d

f
u
n
c
t
i
o
n
s
.

M
o
r
e

i
n
f
o
r
m
a
t
i
o
n

o
n

h
o
w

t
o

u
s
e

t
h
e

s
t
a
n
d
a
r
d

l
i
b
r
a
r
y

f
u
n
c
t
i
o
n
s

c
a
n

b
e

a
c
c
e
s
s
e
d

a
t
:

h
t
t
p
:
/
/
a
r
d
u
i
n
o
.
c
c
/
e
n
/
R
e
f
e
r
e
n
c
e
/
L
i
b
r
a
r
i
e
s
.
E
x
p
a
n
d

y
o
u
r

h
o
r
i
z
o
n
s

u
s
i
n
g

L
i
b
r
a
r
i
e
s
:
F
i
l
e
E
d
i
t
S
k
e
t
c
h
T
o
o
l
s
H
e
l
p
E
E
P
R
O
M
E
t
h
e
r
n
e
t
F
i
r
m
a
t
a
L
i
q
u
i
d
C
r
y
s
t
a
l
S
D
S
e
r
v
o
S
o
f
t
w
a
r
e
S
e
r
i
a
l
S
P
I
S
t
e
p
p
e
r
W
i
r
e
V
e
r
i
f
y

/

C
o
m
p
i
l
e
S
h
o
w

S
k
e
t
c
h

F
o
l
d
e
r
A
d
d

F
i
l
e
.
.
.
I
m
p
o
r
t

L
i
b
r
a
r
y
Circuit 2
Arduino Code:
8
Troubleshooting:
Servo Not Twisting
Even with colored wires it is still shockingly easy to plug a
servo in backward. Tis might be the case.
Still Not Working
A mistake we made a time or two was simply forgetting
to connect the power (red and brown wires) to +5 volts
and ground.
Fits and Starts
If the servo begins moving then twitches, and there's a
fashing light on your RedBoard, the power supply you
are using is not quite up to the challenge. Using a wall
adapter instead of USB should solve this problem.
You should see your servo motor move to
various locations at several speeds. If the
motor doesn't move, check your
connections and make sure you have
verifed and uploaded the code, or see the
troubleshooting tips below.
Code to Note:
Real World Application:
Robotic arms you might see in an assembly line or sci-f
movie probably have servos in them.
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 8
What You Should See:
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G

I
N
D
I
G
I
T
A
L

(
P
W
M
~
)
O
N
I
S
P
T
X
R
X
#include is a special "preprocessor" command that inserts a library (or any
other fle) into your sketch. You can type this command yourself, or
choose an installed library from the "sketch / import library" menu.
#include <Servo.h>
Te servos in this kit don't spin all the way around, but they can be commanded
to move to a specifc position. We use the servo library's write() command to
move a servo to a specifed number of degrees(0 to 180). Remember that the
servo requires time to move, so give it a short delay() if necessary.
servo1.write(180);
Te servo library adds new commands that let you control a servo. To
prepare the Arduino to control a servo, you must frst create a Servo
"object" for each servo (here we've named it "servo1"), and then "attach" it
to a digital pin (here we're using pin 9).
Servo servo1;
servo1.attach(9);
P
A
R
T
S
:
IC
1 X
330
Resistor
8 X
LED
8 X
In this circuit, we will use a fex sensor to measure,
well, fex! A fex sensor uses carbon on a strip of
plastic to act like a variable resistor, but instead of
changing the resistance by turning a knob, you
change it by fexing (bending) the component. We
use a "voltage divider" again to detect this change in
resistance. Te sensor bends in one direction and the
more it bends, the higher the resistance gets; it has a
range from about 10K ohm to 35K ohm. In this
circuit we will use the amount of bend of the fex
sensor to control the position of a servo.
Flex Sensor
P
A
R
T
S
:
CIRCUIT #9
9
Potentiometer
1 X
Servo
1 X
Flex Sensor
1 X
10K
Resistor
1 X
Wire
11 X
p.10
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
(
P
W
M
~
)
O
N
I S
P
T
X
R
X
p.52
RedBoard
Resistor (10K ohm)
Flex Sensor
(Brown-Black-Orange)
GND
SIG
V+
W
R
B
5 volt
(Ground)
GND
PIN 9 PIN A0
I
O
R
E
F
R
E
S
E
T
RESET
7
-
1
5
V
S
C
L
S
D
A
A
R
E
F
G
N
D
1
3
1
2
~
1
1
~
1
0
~
987
~
6
~
54
~
3210
TX
RX
13
3
.
3
V
5
V
G
N
D
G
N
D
V
I
N
A
0
A
1
A
2
A
3
A
4
A
5
POWER ANALOG IN
DIGITAL (PWM~)
ON
ISP
T
X
R
X
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
C
i
r
c
u
i
t

9
:

F
l
e
x

S
e
n
s
o
r
I
t

h
a
p
p
e
n
s

t
o

e
v
e
r
y
o
n
e

-

y
o
u

w
r
i
t
e

a

s
k
e
t
c
h

w
h
i
c
h

s
u
c
c
e
s
s
f
u
l
l
y

c
o
m
p
i
l
e
s

a
n
d

u
p
l
o
a
d
s
,

b
u
t

y
o
u

c
a
n
'
t

f
g
u
r
e

o
u
t

w
h
y

i
t
'
s

n
o
t

d
o
i
n
g

w
h
a
t

y
o
u

w
a
n
t

i
t

t
o
.

L
a
r
g
e
r

c
o
m
p
u
t
e
r
s

h
a
v
e

s
c
r
e
e
n
s
,

k
e
y
b
o
a
r
d
s
,

a
n
d

m
i
c
e

t
h
a
t

y
o
u

c
a
n

u
s
e

t
o

d
e
b
u
g

y
o
u
r

c
o
d
e
,

b
u
t

t
i
n
y

c
o
m
p
u
t
e
r
s

l
i
k
e

t
h
e

R
e
d
B
o
a
r
d

h
a
v
e

n
o

s
u
c
h

t
h
i
n
g
s
.
T
e

k
e
y

t
o

v
i
s
i
b
i
l
i
t
y

i
n
t
o

a

m
i
c
r
o
c
o
n
t
r
o
l
l
e
r

i
s

o
u
t
p
u
t
.

T
i
s

c
a
n

b
e

a
l
m
o
s
t

a
n
y
t
h
i
n
g
,

i
n
c
l
u
d
i
n
g

L
E
D
s

a
n
d

b
u
z
z
e
r
s
,

b
u
t

o
n
e

o
f

t
h
e

m
o
s
t

u
s
e
f
u
l

t
o
o
l
s

i
s

t
h
e

s
e
r
i
a
l

m
o
n
i
t
o
r
.

U
s
i
n
g

S
e
r
i
a
l
.
p
r
i
n
t
(
)

a
n
d

p
r
i
n
t
l
n
(
)
,

y
o
u

c
a
n

e
a
s
i
l
y

o
u
t
p
u
t

h
u
m
a
n
-
r
e
a
d
a
b
l
e

t
e
x
t

a
n
d

d
a
t
a

f
r
o
m

t
h
e

R
e
d
B
o
a
r
d

t
o

a

w
i
n
d
o
w

b
a
c
k

o
n

t
h
e

h
o
s
t

c
o
m
p
u
t
e
r
.

T
i
s

i
s

g
r
e
a
t

f
o
r

y
o
u
r

s
k
e
t
c
h
'
s

f
n
a
l

o
u
t
p
u
t
,

b
u
t

i
t
'
s

a
l
s
o

i
n
c
r
e
d
i
b
l
y

u
s
e
f
u
l

f
o
r

d
e
b
u
g
g
i
n
g
.
D
e
b
u
g
g
i
n
g

y
o
u
r

s
k
e
t
c
h
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
u
s
t

a
d
d

S
e
r
i
a
l
.
b
e
g
i
n
(
9
6
0
0
)
;

t
o

y
o
u
r

s
e
t
u
p
(
)

f
u
n
c
t
i
o
n
,

a
n
d

a
d
d

a

S
e
r
i
a
l
.
p
r
i
n
t
(
)

o
r

p
r
i
n
t
l
n
(
)

t
o

y
o
u
r

l
o
o
p
:
f
o
r

(
x

=

0
;

x

<

8
;

x
+
+
)
{





S
e
r
i
a
l
.
p
r
i
n
t
(
x
)
;
}
Controller accessories for video game consoles like
Nintendos Power Glove use fex-sensing technology. It
was the frst video game controller attempting to mimic
hand movement on a screen in real time.
Circuit 2
Arduino Code:
9
Troubleshooting:
Servo Not Twisting
Even with colored wires it is still shockingly easy to plug a
servo in backwards. Tis might be the case.
Servo Not Moving as Expected
Te sensor is only designed to work in one direction. Try
fexing it the other way (where the striped side faces
out on a convex curve).
Servo Doesnt Move very Far
You need to modify the range of values in the call to the
map() function.
You should see the servo motor move in
accordance with how much you are
fexing the fex sensor. If it isn't
working, make sure you have assembled
the circuit correctly and verifed and
uploaded the code to your board or see
the troubleshooting tips below.
Code to Note:
Real World Application:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 9
What You Should See:
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
( P
W
M
~
)
O
N
I S
P
T
X
R
X
Because the fex sensor / resistor combination won't give us a
full 0 to 5 volt range, we're using the map() function as a
handy way to reduce that range. Here we've told it to only
expect values from 600 to 900, rather than 0 to 1023.
servoposition = map(flexposition, 600, 900, 0, 180);
Because map() could still return numbers outside the "to"
range, we'll also use a function called constrain() that will
"clip" numbers into a range. If the number is outside the
range, it will make it the largest or smallest number. If it is
within the range, it will stay the same.
servoposition = constrain(servoposition, 0, 180);
map(value, fromLow, fromHigh, toLow, toHigh)
constrain(x, a, b)
Circuit 2
P
A
R
T
S
:
CIRCUIT #5
p.10
IC
1 X
330
Resistor
8 X
LED
8 X
Circuit 2
In this circuit, we are going to use yet another kind of
variable resistor this time, a soft potentiometer (or
soft pot). Tis is a thin and fexible strip that can
detect where pressure is being applied. By pressing
down on various parts of the strip, you can vary the
resistance from 100 to 10K ohms. You can use this
ability to track movement on the soft pot, or simply
as a button. In this circuit, well get the soft pot up
and running to control an RGB LED.
Soft Potentiometer
P
A
R
T
S
:
CIRCUIT #10
10
p.56
Wire
9 X
330
Resistor
3 X
LED
1 X
Soft Potentiometer
1 X
330
Resistor
3 X
10K
Resistor
1 X
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
(
P
W
M
~
)
O
N
I S
P
T
X
R
X
RedBoard
Soft Pot
RedBoard
R
E
D
G
R
E
E
N
B
L
U
E
5 volt
GND
(Ground)
Resistors (330 ohm)
(Orange-Orange-Brown)
Resistor (10K ohm)
(Brown-Black-Orange)
PIN A0
PIN 11
PIN 10
PIN 9
LED
(Light-Emitting Diode)
I
O
R
E
F
R
E
S
E
T
RESET
7
-
1
5
V
S
C
L
S
D
A
A
R
E
F
G
N
D
1
3
1
2
~
1
1
~
1
0
~
987
~
6
~
54
~
3210
TX
RX
13
3
.
3
V
5
V
G
N
D
G
N
D
V
I
N
A
0
A
1
A
2
A
3
A
4
A
5
POWER ANALOG IN
DIGITAL (PWM~)
ON
ISP
T
X
R
X
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
C
i
r
c
u
i
t

1
0
:

S
o
f
t

P
o
t
e
n
t
i
o
m
e
t
e
r
C
o
m
p
o
n
e
n
t
:
I
m
a
g
e

R
e
f
e
r
e
n
c
e
:
C
o
m
p
o
n
e
n
t
:
I
m
a
g
e

R
e
f
e
r
e
n
c
e
:
J
u
m
p
e
r

W
i
r
e
G
N
D
R
G
B

L
E
D

(
5
m
m
)
a
4
a
5
a
6
a
7
e
7
e
1
1
5
V
3
3
0


R
e
s
i
s
t
o
r
g
4
e
4
e
7
e
1
1
5
V
3
3
0


R
e
s
i
s
t
o
r
g
6
e
6
e
7
e
1
1
5
V
3
3
0


R
e
s
i
s
t
o
r
g
7
e
7
J
u
m
p
e
r

W
i
r
e
5
V
5
V
+
J
u
m
p
e
r

W
i
r
e
P
i
n

9
h
4
J
u
m
p
e
r

W
i
r
e
P
i
n

1
0
h
6
J
u
m
p
e
r

W
i
r
e
P
i
n

1
1
h
7
e
5
J
u
m
p
e
r

W
i
r
e
j
1
8
+
J
u
m
p
e
r

W
i
r
e
j
2
0
J
u
m
p
e
r

W
i
r
e
J
u
m
p
e
r

W
i
r
e
j
1
9
A
0
5
V
S
o
f
t

P
o
t
e
n
t
i
o
m
e
t
e
r
h
1
9
h
1
8
h
2
0
1
0
K


R
e
s
i
s
t
o
r
i
1
9
Te knobs found on many objects, like a radio for
instance, are using similar concepts to the one you just
completed for this circuit.
Circuit 2
Arduino Code:
10
Troubleshooting:
LED Remains Dark or Shows Incorrect Color
With the four pins of the LED so close together, its
sometimes easy to misplace one. Try double checking each
pin is where it should be.
Bizarre Results
Te most likely cause of this is if youre pressing the
potentiometer in more than one position. Tis is normal
and can actually be used to create some neat results.
You should see the RGB LED change
colors in accordance with how you
interact with the soft potentiometer.
If it isn't working, make sure you
have assembled the circuit correctly
and verifed and uploaded the code to
your board, or see the
troubleshooting tips below.
These big, scary functions take a single
Value (RGBposition) and calculate the
three RGB values necessary to create a
rainbow of color. The functions create
three "peaks" for the red, green, and
blue values, which overlap to mix and
create new colors. See the code for more
information! Even if you're not 100%
clear how it works, you can copy and
paste this (or any) function into your
own code and use it yourself. If you
want to know more about creating your
own functions - take a look at circuit
#11.
redValue = constrain(map(RGBposition, 0, 341, 255, 0), 0, 255)
+ constrain(map(RGBposition, 682, 1023, 0, 255), 0, 255);

greenValue = constrain(map(RGBposition, 0, 341, 0, 255), 0, 255)
- constrain(map(RGBposition, 341, 682, 0,255), 0, 255);
blueValue = constrain(map(RGBposition, 341, 682, 0, 255), 0, 255)
- constrain(map(RGBposition, 682, 1023, 0, 255), 0, 255);

Code to Note:
Real World Application:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 10
What You Should See:
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G

I
N
D
I
G
I
T
A
L

(
P
W
M
~
)
O
N
I
S
P
T
X
R
X
Circuit 2
In this circuit, we'll again bridge the gap between the
digital world and the analog world. We'll be using a
buzzer that makes a small "click" when you apply
voltage to it (try it!). By itself that isn't terribly
exciting, but if you turn the voltage on and of
hundreds of times a second, the buzzer will produce a
tone. And if you string a bunch of tones together,
you've got music! Tis circuit and sketch will play a
classic tune. We'll never let you down!
Buzzer
P
A
R
T
S
:
Wire
3 X
CIRCUIT #11
11
p.60
Piezo Element
1 X
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
(
P
W
M
~
)
O
N
I S
P
T
X
R
X
If the buzzer doesn't easily t
into the holes on the breadboard,
try rotatng it slightly.
GND
(Ground)
RedBoard
Piezo Buzzer
PIN 9
I
O
R
E
F
R
E
S
E
T
RESET
7
-
1
5
V
S
C
L
S
D
A
A
R
E
F
G
N
D
1
3
1
2
~
1
1
~
1
0
~
987
~
6
~
54
~
3210
TX
RX
13
3
.
3
V
5
V
G
N
D
G
N
D
V
I
N
A
0
A
1
A
2
A
3
A
4
A
5
POWER ANALOG IN
DIGITAL (PWM~)
ON
ISP
T
X
R
X
C
i
r
c
u
i
t

1
1
:

P
i
e
z
o

E
l
e
m
e
n
t
s
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
C
o
m
p
o
n
e
n
t
:
I
m
a
g
e

R
e
f
e
r
e
n
c
e
:
P
i
e
z
o

E
l
e
m
e
n
t
+
-
f
9
f
7
J
u
m
p
e
r

W
i
r
e
P
i
n

9
j
9
i
7
J
u
m
p
e
r

W
i
r
e
G
N
D
J
u
m
p
e
r

W
i
r
e
A
r
d
u
i
n
o

c
o
n
t
a
i
n
s

a

w
e
a
l
t
h

o
f

b
u
i
l
t
-
i
n

f
u
n
c
t
i
o
n
s

t
h
a
t

a
r
e

u
s
e
f
u
l

f
o
r

a
l
l

k
i
n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;
}
Many modern megaphones have settings that use a loud
amplifed buzzer. Tey are usually very loud and quite
good at getting peoples attention.
Circuit 2
Arduino Code:
11
Troubleshooting:
No Sound
Given the size and shape of the piezo element it is easy to
miss the right holes on the breadboard. Try double
checking its placement.
Can't Tink While the Melody is Playing
Just pull up the piezo element whilst you think, upload
your program then plug it back in.
Feeling Let Down and Deserted
Te code is written so you can easily add your own songs.
You should see - well, nothing!
But you should be able to hear a
song. If it isn't working, make
sure you have assembled the
circuit correctly and verifed and
uploaded the code to your board
or see the troubleshooting tips
below.
Code to Note:
Real World Application:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 11
What You Should See:
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
( P
W
M
~
)
O
N
I S
P
T
X
R
X
Up until now we've been working solely with numerical data, but
the Arduino can also work with text. Characters (single, printable,
letters, numbers and other symbols) have their own type, called
"char". When you have an array of characters, it can be defned
between double-quotes (also called a "string"), OR as a list of
single-quoted characters.
char notes[] = "cdfda ag cdfdg gf ";
char names[] = {'c','d','e','f','g','a','b','C'};
One of Arduino's many useful built-in commands is the tone()
function. Tis function drives an output pin at a certain
frequency, making it perfect for driving buzzers and speakers. If
you give it a duration (in milliseconds), it will play the tone then
stop. If you don't give it a duration, it will keep playing the tone
forever (but you can stop it with another function, noTone() ).
tone(pin, frequency, duration);
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
(
P
W
M
~
)
O
N
I S
P
T
X
R
X
Circuit 2
Remember before when you played around with a servo
motor? Now we are going to tackle spinning a motor.
Tis requires the use of a transistor, which can switch a
larger amount of current than the RedBoard can. When
using a transistor, you just need to make sure its
maximum specs are high enough for your use. Te
transistor we are using for this circuit is rated at 40V max
and 200 milliamps max perfect for our toy motor!
When the motor is spinning and suddenly turned of, the
magnetic feld inside it collapses, generating a voltage
spike. Tis can damage the transistor. To prevent this, we
use a "fyback diode", which diverts the voltage spike
around the transistor.

Spinning a Motor
P
A
R
T
S
:
Wire
6 X
CIRCUIT #12
12
1 X
DC Motor
1 X
Diode
1N4148
p.64
Transistor
P2N2222AG
1 X
When youre building the circuit be careful not
to mix up the transistor and the temperature
sensor, theyre almost identical. Look for
P2N2222A on the body of the transistor.
330
Resistor
1 X
P
2
N
2
2
2
2
A
FRONT
BACK
RedBoard
Resistor (330 ohm)
(Orange-Orange-Brown)
Transistor
(P2N2222AG)
DC Motor
Diode
(1N4148)
GND
(Ground)
5 volt
PIN 9
COLLECTOR
BASE
EMITTER
EMITTER
BASE
COLLECTOR
I
O
R
E
F
R
E
S
E
T
RESET
7
-
1
5
V
S
C
L
S
D
A
A
R
E
F
G
N
D
1
3
1
2
~
1
1
~
1
0
~
987
~
6
~
54
~
3210
TX
RX
13
3
.
3
V
5
V
G
N
D
G
N
D
V
I
N
A
0
A
1
A
2
A
3
A
4
A
5
POWER ANALOG IN
DIGITAL (PWM~)
ON
ISP
T
X
R
X
C
i
r
c
u
i
t

1
2

:

S
p
i
n
n
i
n
g

a

M
o
t
o
r
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
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p
e
a
t
!

(
O
r

n
o
t
!
)
W
e
'
v
e

a
l
r
e
a
d
y

s
h
o
w
n

y
o
u

h
o
w

t
o

u
s
e

a

b
u
n
c
h

o
f

d
i
f
e
r
e
n
t

i
n
p
u
t

s
e
n
s
o
r
s

a
n
d

o
u
t
p
u
t

d
e
v
i
c
e
s

(
a
n
d

w
e

s
t
i
l
l

h
a
v
e

a

f
e
w

m
o
r
e

t
o

g
o
)
.

F
e
e
l

f
r
e
e

t
o

m
a
k
e

u
s
e

o
f

t
h
e

e
x
a
m
p
l
e
s

i
n

y
o
u
r

o
w
n

s
k
e
t
c
h
e
s

-

t
h
i
s

i
s

t
h
e

w
h
o
l
e

i
d
e
a

b
e
h
i
n
d

t
h
e

"
O
p
e
n

S
o
u
r
c
e
"

m
o
v
e
m
e
n
t
.
I
t
'
s

u
s
u
a
l
l
y

p
r
e
t
t
y

e
a
s
y

t
o

p
u
l
l

p
i
e
c
e
s

o
f

d
i
f
e
r
e
n
t

s
k
e
t
c
h
e
s

t
o
g
e
t
h
e
r
,

j
u
s
t

o
p
e
n

t
h
e
m

i
n

t
w
o

w
i
n
d
o
w
s
,

a
n
d

c
o
p
y

a
n
d

p
a
s
t
e

b
e
t
w
e
e
n

t
h
e
m
.

T
i
s

i
s

o
n
e

o
f

t
h
e

r
e
a
s
o
n
s

w
e
'
v
e

b
e
e
n

p
r
o
m
o
t
i
n
g

"
g
o
o
d

p
r
o
g
r
a
m
m
i
n
g

h
a
b
i
t
s
"
.

T
i
n
g
s

l
i
k
e

u
s
i
n
g

c
o
n
s
t
a
n
t
s

f
o
r

p
i
n

n
u
m
b
e
r
s
,

a
n
d

b
r
e
a
k
i
n
g

y
o
u
r

s
k
e
t
c
h

i
n
t
o

f
u
n
c
t
i
o
n
s
,

m
a
k
e

i
t

m
u
c
h

e
a
s
i
e
r

t
o

r
e
-
u
s
e

y
o
u
r

c
o
d
e

i
n

n
e
w

s
k
e
t
c
h
e
s
.

F
o
r

e
x
a
m
p
l
e
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r
d
u
i
n
o

e
x
a
m
p
l
e
s

f
o
r

t
h
e
m
.

S
e
e

o
u
r

p
r
o
d
u
c
t

p
a
g
e
s

f
o
r

i
n
f
o
.
F
i
n
a
l
l
y
,

w
h
e
n

y
o
u

c
r
e
a
t
e

s
o
m
e
t
h
i
n
g

r
e
a
l
l
y

c
o
o
l
,

c
o
n
s
i
d
e
r

s
h
a
r
i
n
g

i
t

w
i
t
h

t
h
e

w
o
r
l
d

s
o

t
h
a
t

o
t
h
e
r
s

c
a
n

l
e
a
r
n

f
r
o
m

y
o
u
r

g
e
n
i
u
s
.

B
e

s
u
r
e

t
o

l
e
t

u
s

k
n
o
w

o
n

h
t
t
p
s
:
/
/
w
w
w
.
s
p
a
r
k
f
u
n
.
c
o
m
/
p
r
o
j
e
c
t
_
c
a
l
l
s

s
o

w
e

c
a
n

p
u
t

i
t

o
n

o
u
r

h
o
m
e

p
a
g
e
!
P
u
t
t
i
n
g

i
t

a
l
l

t
o
g
e
t
h
e
r
:
P 2 N 2
2 2 2 A
C
O
L
L
E
C
T
O
R
B
A
S
E
E
M
I
T
T
E
R
E
B
C
Circuit 2
Arduino Code:
12
Troubleshooting:
Motor Not Spinning
If you sourced your own transistor, double check with
the data sheet that the pinout is compatible with a
P2N2222AG (many are reversed).
Still No Luck
If you sourced your own motor, double check that it will
work with 5 volts and that it does not draw too much
power.
Still Not Working
Sometimes the RedBoard will disconnect from the
computer. Try un-plugging and then re-plugging it into
your USB port.
Te DC Motor should spin if you have
assembled the circuits components correctly,
and also verifed/uploaded the correct code. If
your circuit is not working check the
troubleshooting section below.
Code to Note:
Real World Application:
Radio Controlled(RC) cars use Direct Current(DC)
motors to turn the wheels for propulsion.
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 12
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D G
N
D V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
( P
W
M
~
)
O
N
I S
P
T
X
R
X
What You Should See:
Te RedBoard's serial port can be used to receive as well as send data.
Because data could arrive at any time, the RedBoard stores, or
"bufers" data coming into the port until you're ready to use it. Te
Serial.available() command returns the number of characters that the
port has received, but haven't been used by your sketch yet. Zero
means no data has arrived.
while (Serial.available() > 0)
If the port has data waiting for you, there are a number of ways for
you to use it. Since we're typing numbers into the port, we can
use the handy Serial.parseInt() command to extract, or "parse"
integer numbers from the characters it's received. If you type "1"
"0" "0" to the port, this function will return the number 100.
speed = Serial.parseInt();
Circuit 2
P
A
R
T
S
:
CIRCUIT #5
5
p.10
IC
1 X
LED
8 X
Circuit 2
In this circuit, we are going to use some of the lessons we
learned in circuit 12 to control a relay. A relay is basically
an electrically controlled mechanical switch. Inside that
harmless looking plastic box is an electromagnet that,
when it gets a jolt of energy, causes a switch to trip. In
this circuit, youll learn how to control a relay like a pro
giving your RedBoard even more powerful abilities!
Relays
P
A
R
T
S
:
CIRCUIT #13
13
p.68
Transistor
P2N2222AG
1 X
Relay
1 X 1 X
Diode
1N4148
Wire
14 X
330
Resistor
2 X
LED
2 X
When the relay is of, the COM (common)
pin will be connected to the NC (Normally
Closed) pin. When the relay is on, the COM
(common) pin will be connected to the NO
(Normally Open) pin.
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
(
P
W
M
~
)
O
N
I S
P
T
X
R
X
RedBoard
Transistor
(P2N2222AG)
SPDT Relay
Diode
(1N4148)
Resistor (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p
e
r

W
i
r
e
j
7
j
9
J
u
m
p
e
r

W
i
r
e
i
1
5
e
1
9
J
u
m
p
e
r

W
i
r
e
e
1
5
e
1
9
J
u
m
p
e
r

W
i
r
e
e
1
5
e
1
9
J
u
m
p
e
r

W
i
r
e
b
1
4
e
1
9
J
u
m
p
e
r

W
i
r
e
a
7
a
9
J
u
m
p
e
r

W
i
r
e
e
4
b
9
+
++
J
u
m
p
e
r

W
i
r
e
e
1
5
e
1
9
J
u
m
p
e
r

W
i
r
e
e
1
5
+
J
u
m
p
e
r

W
i
r
e
a
2
3
+
J
u
m
p
e
r

W
i
r
e
G
N
D
J
u
m
p
e
r

W
i
r
e
5
V
5
V
+
J
u
m
p
e
r

W
i
r
e
P
i
n

2
j
3
J
u
m
p
e
r

W
i
r
e
a
2
0
P 2 N 2
2 2 2 A
C
O
L
L
E
C
T
O
R
B
A
S
E
E
M
I
T
T
E
R
E
B
C
Garage door openers use relays to operate. You might be
able to hear the clicking if you listen closely.
Circuit 2
Arduino Code:
13
Troubleshooting:
LEDs Not Lighting
Double-check that you've plugged them in correctly. Te
longer lead (and non-fat edge of the plastic fange) is the
positive lead.
No Clicking Sound
Te transistor or coil portion of the circuit isn't quite
working. Check the transistor is plugged in the right way.
Not Quite Working
Te included relays are designed to be soldered rather than
used in a breadboard. As such you may need to press it in
to ensure it works (and it may pop out occasionally).
When youre building the circuit be careful not to mix up
the temperature sensor and the transistor, theyre almost
identical.
You should be able to hear the
relay contacts click, and see the
two LEDs alternate illuminating
at 1-second intervals. If you
don't, double-check that you
have assembled the circuit
correctly, and uploaded the
correct sketch to the board. Also,
see the troubleshooting tips below.
Code to Note:
Real World Application:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 13
What You Should See:
When we turn on the transistor, which in turn energizes the
relay's coil, the relay's switch contacts are closed. Tis connects the
relay's COM pin to the NO (Normally Open) pin. Whatever
you've connected using these pins will turn on. (Here we're using
LEDs, but this could be almost anything.)
digitalWrite(relayPin, HIGH);
Te relay has an additional contact called NC (Normally Closed).
Te NC pin is connected to the COM pin when the relay is OFF.
You can use either pin depending on whether something should
be normally on or normally of. You can also use both pins to
alternate power to two devices, much like railroad crossing
warning lights.
digitalWrite(relayPin, LOW);
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G

I N
D
I G
I T
A
L

(
P
W
M
~
)
O
N
I S
P
T
X
R
X
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G

I N
D
I G
I T
A
L

(
P
W
M
~
)
O
N
I S
P
T
X
R
X
Circuit 2
Shift Register
P
A
R
T
S
:
Wire
19 X
CIRCUIT #14
14
p.72
Now we are going to step into the world of ICs (integrated
circuits). In this circuit, youll learn all about using a shift
register (also called a serial-to-parallel converter). Te shift
register will give your RedBoard an additional eight outputs,
using only three pins on your board. For this circuit, youll
practice by using the shift register to control eight LEDs.
IC
1 X
330
Resistor
8 X
LED
8 X
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
(
P
W
M
~
)
O
N
I S
P
T
X
R
X
Bend legs to 90 angle.
Align notch on top,
inbetween e5 and f5 on
the breadboard. The notch
indicates where pin 1 is.
1
2
3
4
5
6
7
8
Q
B
Q
C
Q
D
Q
E
Q
F
Q
G
Q
H
GND
V
CC
Q
A
SER
OE
RCLK
SRCLK
SRCLR
Q
H
16
15
14
13
12
11
10
9
*Do not connect pin 9
74HC595
Resistors (330 ohm)
(Orange-Orange-Brown)
LEDs
(Light-Emitting Diodes)
R
e
d
B
o
a
r
d
GND
(Ground)
OE
13
GND
8
QA
15
QB
1
QC
2
QD
3
QE
4
QF
5
QG
6
QH
7
QH*
9
RCK
12
SCK
11
SCL
10
SER
14
VCC
16
5 volt
PIN 2
PIN 3
PIN 4
I
O
R
E
F
R
E
S
E
T
RESET
7
-
1
5
V
S
C
L
S
D
A
A
R
E
F
G
N
D
1
3
1
2
~
1
1
~
1
0
~
987
~
6
~
54
~
3210
TX
RX
13
3
.
3
V
5
V
G
N
D
G
N
D
V
I
N
A
0
A
1
A
2
A
3
A
4
A
5
POWER ANALOG IN
DIGITAL (PWM~)
ON
ISP
T
X
R
X
C
i
r
c
u
i
t

1
4
:

S
h
i
f
t

R
e
g
i
s
t
e
r
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
a
b
c
d
e
f
g
h
i
123456789
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
C
o
m
p
o
n
e
n
t
:
I
m
a
g
e

R
e
f
e
r
e
n
c
e
:
C
o
m
p
o
n
e
n
t
:
I
m
a
g
e

R
e
f
e
r
e
n
c
e
:
L
E
D

(
5
m
m
)
+
-
+
-
c
1
4
c
1
5
L
E
D

(
5
m
m
)
+
-
+
-
c
1
7
c
1
8
L
E
D

(
5
m
m
)
+
-
+
-
c
2
0
c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
u
m
p
e
r

W
i
r
e
a
2
3
a
7
a
3
G
N
D
J
u
m
p
e
r

W
i
r
e
a
2
0
a
6
a
3
G
N
D
J
u
m
p
e
r

W
i
r
e
a
1
7
a
5
J
u
m
p
e
r

W
i
r
e
J
u
m
p
e
r

W
i
r
e
j
7
P
i
n

2
j
9
P
i
n

4
j
1
0
P
i
n

3
a
3
G
N
D
J
u
m
p
e
r

W
i
r
e
j
1
1
a
1
4
+
j
1
0
5
V
+
G
N
D
Similar to circuit #4, a scrolling marquee display delivers
a message with multiple LEDs. Essentially the same task
the shift register achieves here in Circuit #14.
Circuit 2
Arduino Code:
14
Troubleshooting:
Te RedBoard's power LED goes out
Tis happened to us a couple of times, it happens when
the chip is inserted backward. If you fx it quickly
nothing will break.
Not Quite Working
Sorry to sound like a broken record but it is probably
something as simple as a crossed wire.
Frustration
Shoot us an e-mail, this circuit is both simple and
complex at the same time. We want to hear about
problems you have so we can address them in future
editions: techsupport@sparkfun.com
You should see the LEDs light up
similarly to circuit 4 (but this
time, you're using a shift register).
If they aren't, make sure you have
assembled the circuit correctly
and verifed and uploaded the
code to your board. See the
troubleshooting tips below.
Code to Note:
Real World Application:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 14
What You Should See:
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G

I N
D
I G
I T
A
L

(
P
W
M
~
)
O
N
I S
P
T
X
R
X
You'll communicate with the shift register (and a lot of other parts) using an
interface called SPI, or Serial Peripheral Interface. Tis interface uses a data
line and a separate clock line that work together to move data in or out of
the RedBoard at high speed. Te MSBFIRST parameter specifes the order
in which to send the individual bits, in this case we're sending the Most
Signifcant Bit frst.
shiftOut(datapin, clockpin, MSBFIRST, data);
Bits are the smallest possible piece of memory in a computer; each one can
store either a "1" or a "0". Larger numbers are stored as arrays of bits.
Sometimes we want to manipulate these bits directly, for example now when
we're sending eight bits to the shift register and we want to make them 1 or 0
to turn the LEDs on or of. Te RedBoard has several commands, such as
bitWrite(), that make this easy to do.
bitWrite(data, desiredPin, desiredState);
Circuit 2
P
A
R
T
S
:
Wire
19 X
CIRCUIT #5
IC
1 X
330
Resistor
8 X
LED
8 X
Circuit 2
In this circuit, youll learn about how to use an LCD.
An LCD, or liquid crystal display, is a simple screen
that can display commands, bits of information, or
readings from your sensor - all depending on how you
program your board. In this circuit, youll learn the
basics of incorporating an LCD into your project.
LCD
P
A
R
T
S
:
Wire
16 X
CIRCUIT #15
15
LCD
1 X
Potentiometer
1 X
p.76
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
(
P
W
M
~
)
O
N
I S
P
T
X
R
X
R
e
d
B
o
a
r
d
GND
(Ground)
5 volt
A D
B
0
D
B
1
D
B
2
D
B
3
D
B
4
D
B
5
D
B
6
D
B
7
EK R
/
W
R
S
V
D
D
V
O
V
S
S
16x2 LCD
PIN 2
PIN 3
PIN 4
PIN 5
PIN 11
PIN 12
I
O
R
E
F
R
E
S
E
T
RESET
7
-
1
5
V
S
C
L
S
D
A
A
R
E
F
G
N
D
1
3
1
2
~
1
1
~
1
0
~
987
~
6
~
54
~
3210
TX
RX
13
3
.
3
V
5
V
G
N
D
G
N
D
V
I
N
A
0
A
1
A
2
A
3
A
4
A
5
POWER ANALOG IN
DIGITAL (PWM~)
ON
ISP
T
X
R
X
C
i
r
c
u
i
t

1
5
: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
2
9
j
2
8
j
2
7
j
2
6
j
2
5
j
2
4
j
2
3
j
2
2
j
2
1
j
2
0
j
1
9
j
1
8
j
1
7
j
1
6
j
1
5
a
3
G
N
D
J
u
m
p
e
r

W
i
r
e
J
u
m
p
e
r

W
i
r
e
f
2
6
a
3
G
N
D
J
u
m
p
e
r

W
i
r
e
f
2
9
+
a
3
J
u
m
p
e
r

W
i
r
e
f
3
0
f
3
0
LCDs are everywhere! From advanced LCDs like your
television, to simple notifcation screens, this is a very
common and useful display!
Circuit 2
Arduino Code:
15
Troubleshooting:
Te Screen is Blank or Completely Lit?
Fiddle with the contrast by twisting the potentiometer. If
its incorrectly adjusted, you wont be able to read the
text.
Not Working At All?
Double check the code, specifcally that you include the
LCD library.
Screen Is Flickering
Double check your connections to your breadboard and
Arduino.
Initially, you should see the
words hello, world! pop up
on your LCD. Remember you
can adjust the contrast using
the potentiometer if you cant
make out the words clearly. If
you have any issues, make sure
your code is correct and
double-check your
connections.
Tis bit of code tells your Arduino IDE to include the library for a
simple LCD display. Without it, none of the commands will work,
so make sure you include it!
#include <LiquidCrystal.h>
Code to Note:
Real World Application:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 15
What you Should See:
Tis is the frst time youll fre something up on your screen. You
may need to adjust the contrast to make it visible. Twist the
potentiometer until you can clearly see the text!
lcd.print(hello, world!);
IO
R
E
F R
E
S
E
T
R
E
S
E
T
7
-
1
5
V
S
C
L S
D
A
A
R
E
F G
N
D
1
3
1
2 ~
1
1 ~
1
0
~
9
8
7
~
6
~
5
4
~
3
2
1
0
T
X
R
X
1
3
3
.3
V 5
V
G
N
D
G
N
D
V
IN
A
0
A
1
A
2
A
3
A
4
A
5
P
O
W
E
R
A
N
A
L
O
G
I N
D
I G
I T
A
L
(
P
W
M
~
)
O
N
I S
P
T
X
R
X
Tis is just the beginning of your exploration into embedded
electronics and coding. Our website has a wealth of tutorials to
whet your appetite for more knowledge. We also host a
community of hackers, engineers, DIYers, etc. in our forums. So
log on to our website for more information about Arduino, or to
plan ahead for your next project!
sparkfun.com
Visit us Online:
Learning More
NOTES:
Begin your Journey
into Electronics
This kit will guide you through
experiments of varying difculty
as you learn all about embedded
systems, physical computing,
programming and more! This kit is
perfect for anyone who wants to
explore the power of the RedBoard
platform.
KIT INCLUDES
SparkFun Electronics, inc. All rights reserved. The SparkFun Inventors kit for the SparkFun RedBoard features, specications, system
requirements and availability are subject to change without notice. All other trademarks contained herein are the property of their respective owners.
The SIK Guide for the SparkFun Inventors Kit for the SparkFun RedBoard is licensed under
the Creative Commons Attribution Share-Alike 3.0 Unported License
To view a copy of this license visit: http://creativecommons.org/by-sa/3.0/
Or write: Creative Commons, 171 Second Street, Suite 300, San Francisco, CA 94105, USA.
The SparkFun Inventors Kit
teaches basic programming,
for which you will need both a
computer and an internet connection.
You will also learn to
assemble 15 basic physical
electronic circuits, but no
soldering is required. No previous
experience is necessary!
SparkFun RedBoard
Breadboard
Instruction booklet
Sealed relay
Small servo
Yellow and red LEDs
RGB LED
Temperature sensor
DC motor
8-bit shift register
Push button switches
Potentiometer
Photoresistor
Transistors
Jumper wires
USB cable
Signal diodes
10k ohm resistors
330 ohm resistors
Piezo buzzer
Flex sensor
Soft potentiometer
Baseplate
LCD

You might also like