RedBoard SIK 3.2
RedBoard SIK 3.2
RedBoard SIK 3.2
RX
~3
2
TX
~6
~5
4
~9
8
D 7
IG
6
IT ~
AL ~5
(P 4
W
3
M ~
EF
10
11
12
ET
13
TX
L
SC A
SD EF
AR ND
G 13
RX
IS
ES
SE
ER
VI
IOR
RE
W
D
IN
3V
T
3.
SE
GN
PO
D
AN
A5
Version 3.2
ON
OR
TF
LA
EN
PM
VE
DE
GE
UA
NG
LA
INO
DU
DIG
I TA
L(
PW
M~
)
AR
LO
15
15
F
RE
RE
GN
A1
A4
AL
O
A3
RX
TX
TP
7-
7-
IO
5V
A0
A2
SIK GUIDE
Table of Contents
Welcome to the SparkFun Inventors Guide
The SparkFun Inventor's Guide is your map for navigating the
waters of beginning embedded electronics. This booklet contains
all the information you will need to explore the 16 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
Section 1:
Getting Started
What is the RedBoard platform?
Install Drivers
Section 2:
10
Inventory of Parts
12
RedBoard
14
Breadboard
16
18
Circuit #2 - Potentiometer
25
29
33
37
41
45
49
53
57
61
65
69
73
77
81
Page 1
www.sparkfun.com
RedBoard
7-15V
IOREF
FPO
FPO
13
TX
RX
RESET
// SparkFun RedBoard
RESET
5V
GND
VIN
POWER
GND
A0
A1
A3
Page 2
ISP
A5
ON
A4
ANALOG IN
A2
DIGITAL (PWM~)
3.3V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
TX 1
RX 0
c
b
f
a
Auto-Coffee Maker
Auto-Plant Watering
Quadcopter
NW
NE
E
SE
SW
arduino.cc/en/main/software
Download
Windows
Mac OS
X
Mac OS X
Linux: 32 bit, 64 bit
Linux:source
32 bit, 64 bit
user
Choose the appropriate Operating System installation package for your computer.
Page 4
715
V
IO
F
RE
RE
3V
3.
SE
5V
ER
VI
SE
GN
PO
RE
GN
A0
A1
13
N
.
10
11
12
S
H
IN
A5
L
SC A
SD EF
AR ND
G 13
TX
L
E
RX
A4
AL
A3
AN
A2
~
9
O
N
TX
RX
D 7
IG
6
TI A ~ 5
L ~ 4
(P
W
3
M ~
~ 2
)
1
IS
Page 5
Page 6
2 Upload: Sends your code to the RedBoard. When you click it, you should see the lights on your board blink rapidly. // See Diagram Below
3 New: This buttons opens up a new code window tab.
4 Open: This button will let you open up an existing sketch. // See Diagram Below
5 Save: This saves the currently active sketch.
6 Serial Monitor: This will open a window that displays any serial information your RedBoard is transmitting. It is very useful for debugging.
7 Sketch Name: This shows the name of the sketch you are currently working on.
8 Code Area: This is the area where you compose the code for your sketch.
9 Message Area: This is where the IDE tells you if there were any errors in your code.
// The three most important commands for this guide are seen below:
Open
Verify
Upload
Page 7
Note:
http://www.arduino.cc/playground/Learning/Linux
Page 8
Download Arduino Code (For use with the circuits in this guide)
5
Type in the following URL to download the code:
sparkfun.com/sikcode
Start
Programs
arduino
examples
Contents
Resources
Java
examples
Copy the SIK Guide Code folder into
Arduinos folder named examples.
http://www.arduino.cc/playground/Learning/Linux
WHATS NEXT? Read on to learn more about getting started with circuits. Then you can start on your first circuit on page 17!
Page 9
Page 10
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
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
Page 11
Inventory of Parts
LED (5mm)
Jumper Wire
x30
x5
330 Resistor
x25
x5
x5
x5
* ACTUAL SIZE
x1
* ACTUAL SIZE
x25
Diode
(1N4148)
x1
* ACTUAL SIZE
x2
Piezo Buzzer
Photo Resistor
x1
x1
Transistor
(TMP36)
P2N2
222A
A18
Temp. Sensor
(P2N2222AG)
FRONT
x1
DC Motor
FRONT
BACK
x2
Push Button
x1
10K Resistor
Potentiometer
Page 12
Various Colors
x4
BACK
Flex Sensor
SparkFun RedBoard
RESET
x1
7-15V
Soft Potentiometer
13
TX
RX
IOREF
RESET
5V
GND
VIN
POWER
GND
A0
A1
A2
A3
ISP
A5
7
~6
~5
4
~3
2
TX 1
RX 0
ON
A4
ANALOG IN
x1
DIGITAL (PWM~)
3.3V
Servo
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
x1
Breadboard
x1
a b c d e
Integrated Circuit
Relay
(IC)
x1
x1
LCD
x1
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
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
x1
Page 13
RESET
2
1
7-15V
13
TX
RX
IOREF
RESET
5V
10
VIN
POWER
GND
A0
A1
A3
Page 14
ISP
A5
7
9
ON
A4
ANALOG IN
A2
DIGITAL (PWM~)
3.3V
GND
SCL
SDA
AREF
3 4 5
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
TX 1
RX 0
SparkFun RedBoard
1 Power In (Barrel Jack) - Can be used with either a 9V or 12V wall-wart or battery.
2 Power In (USB Port) - Provides power and communicates with your board when plugged into your computer via USB.
LED (RX: Receiving) - This shows when the FTDI chip is receiving data bits from the microcontroller. This happens when the microcontroller is
3 sending
data bits back to the computer.
LED (TX: Transmitting) - This shows when the FTDI chip is transmitting data bits to the microcontroller. This happens when the
4 microcontroller
is receiving this data from the computer.
- This LED is incorporated into your sketch to show if your program is running properly.
6 Pins (ARef, Ground, Digital, Rx, Tx) - These various pins can be used for inputs, outputs, power, and ground. // See Diagram Below
7 LED (Indicates RedBoard is ON) - This is a simple power indicator LED.
8 Reset Button - This is a way to manually reset your RedBoard, which makes your code restart.
9 ICSP Pins (Uploading Code without Bootloader)
- This is for "In-Circuit Serial Programming," used if you want to bypass the bootloader.
10 Pins (Analog In, Power In, Ground, Power Out, Reset) - These various pins can be used for inputs, outputs, power, and ground. // See Diagram
11 RFU - This pin is reserved for future use.
// Pins Diagram
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.
SCL
SDA
ARef
11 RFU
IOREF
Reset
Power Out
Power Out
Ground
Ground
10
Power In
Ground
Digital
Digital
Digital
Digital
Digital
Digital
Digital
Digital
Analog
Digital
Analog
Digital
Analog
Digital
Analog
Digital
Analog
TX - Out
Analog
RX - In
= PWM/Analog out compatible (i.e.
)
Page 15
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
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.
Page 16
Breadboard
1 Vertical Connection (+ Power and - Ground) - Power bus // See Diagram Below
2 Horizontal Connection (a-e & f-j) // See Diagram Below)
Making a Connection:
Above the breadboard
LED
CONNECTED!
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
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
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 five horizontal sockets.
Components placed in the same row will be
connected in a circuit when power is running.
Page 17
ASSEMBLE
WRITE
UPLOAD
RESET
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
7-15V
13
TX
RX
IOREF
RESET
5V
GND
VIN
POWER
GND
A0
A1
A3
TX
RX
ISP
A5
ON
A4
ANALOG IN
A2
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
DIGITAL (PWM~)
3.3V
7
~6
~5
4
~3
2
1
0
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
f g h i
715
V
IO
RE
F
RE
5V
3V
3.
SE
GN
PO
WE
A0
SE
VI
RE
GN
A1
A2
13 X
T
AN
LE
N.
AR
SH
AR
12
E.
10
~
9
8
7
I TA
PW
L(
M~
OG
IN
HA
.
CK
11
DIG
AL
A5
RX
A4
L
SC A
SD EF
AR ND
G 13
A3
ISP
ON
TX
RX
Your RedBoard runs on 5V. This 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. The on-board voltage regulator can handle anything from 7 to 15VDC.
Page 18
Circuit 2
Blinking an LED
PIN 13 RedBoard
LED
(Light-Emitting Diode)
GND
(Ground)
PARTS:
LED
330
Resistor
Wire
715
V
IO
F
RE
RE
5V
3V
3.
SE
SE
T
ER
VI
PO
RE
GN
GN
A0
A1
L
SC A
SD EF
AR ND
G 13
RX
TX
13
.
S
IN
A5
A4
AL
O
A3
AN
A2
10
11
A
C
12
~
9
D 7
I
6
IG T ~
AL ~5
(P 4
W
3
M ~
~ 2
IS
O
N
)
TX
RX
Page 20
a b c d e
RESET
7-15V
13
TX
RX
IOREF
RESET
5V
GND
VIN
POWER
GND
A0
A1
A3
ISP
A5
ON
A4
ANALOG IN
A2
DIGITAL (PWM~)
3.3V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
TX 1
RX 0
1
2
3
4
5
6
7
330 Resistor: The color banding
8
should read orange-or9
ange-brown-gold. The compo10
nent legs can go in either hole.
11
I
12
13
14
15
16
17
18
19
20
21
22
Jumper Wire: All jumper wires
work the same. They are used to 23
24
connect two points together. This
guide will show the wires with dierent
25
colored insulations for clarity, but using
26
dierent combinations of colors is
27
completely acceptable.
28
29
30
f g h i
1
2
3
4
5
LED: Make sure the short leg,6
marked with at side, goes into
7
the negative position (-).
8
9
10
11
12
13
14
Flat Edge
15
16
17
18
Short Leg
19
20
21
22
23
24
25
26
27
28
29
30
a b c d e
f g h i
Component:
LED (5mm)
Image Reference:
-
330 Resistor
c2
c3
a3
GND
a3
Components like LEDs are inserted into the breadboard sockets c2(long leg) c3(short leg). Steps
highlighted with a yellow warning triangle represent a polarized component. Pay special attention to
the components markings indicating how to place it on the breadboard.
Resistors are placed in breadboard sockets only. The - symbol represents any socket in its vertical
column on the Power bus.
Jumper Wire
GND
Jumper Wire
5V
Jumper Wire
Pin 13
e2
GND on the RedBoard should be connected to the row marked - on the breadboard.
Page 21
New
Open...
Sketchbook
Examples
Close
Save
Save As...
Upload
Upload Using Progammer
Page Setup
Print
Help
1.Basics
2.Digital
3.Analog
4.Communication
5.Control
6.Sensors
7.Displays
8.Strings
ArduinoISP
SIK Guide Code
Circuit
Circuit
Circuit
Circuit
Circuit
Circuit
Circuit
Circuit
Circuit
Circuit
Circuit
Circuit
Circuit
Circuit
Circuit
Circuit
EEPROM
Ethernet
Firmata
Liquid Crystal
SD
Servo
SoftwareSerial
SPI
Stepper
Wire
#1
#2
#3
#4
#5
#6
#7
#8
#9
#10
#11
#12
#13
#14
#15
#16
// Circuit #1
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);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
Page 22
//
//
//
//
Verify
This compiles your code. The IDE changes it from text into instructions the computer
can understand.
Upload
This sends the instructions via the USB cable to the computer chip on the RedBoard. The
RedBoard will then begin running your code automatically.
// The result of a completed circuit with correct code after verified and uploaded.
V
15
7-
3V
3.
F
RE
IO SET
RE
RE
SE
T
P
5V D O W
GN D E R
GN
N
VI
A0
LE
AR
.S
N
IN
AR
H
AC
H
K.
IS
P
O
N
12
11
~ 0
1
~ 9
~
8
D 7
IG
6
IT ~
AL ~5
(P 4
W
3
M ~
~ 2
)
1
E.
A5
L
SC A
SD EF
AR ND
G 13
A4
TX
13
R1X3
T TX
RX X
AN
A1
AL
O
A2
G
A3
RX
Page 23
Arduino Code:
Circuit 2
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 1
Code to Note:
pinMode(13, OUTPUT);
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.
digitalWrite(13, HIGH);
V
15
7-
5V
PO
RE
SE
T
D W
GN D E R
GN
N
VI
A0
A1
LE
H
.S
N
IN
A5
AR
A4
L
SC A
SD EF
AR ND
G 13
A3
AR
E.
AC
K.
O
N
12
11
~ 0
1
~
9
~
8
D 7
IG
6
IT ~
5
A
~
L
(P 4
W
3
M ~
~ 2
)
1
IS
P
RX
13
R1X3
T TX
RX X
AN
AL
O
G
A2
Troubleshooting:
Page 24
Circuit 2
CIRCUIT
#5
#2
Potentiometer
PIN 13 RedBoard
5 volt
LED
(Light-Emitting Diode)
Potentiometer
PIN A0
RedBoard
PARTS:
GND
(Ground)
IC
Potentiometer
LED
X
330
Resistor
Wire
18
18
19
6
715
V
IO
F
RE
RE
5V
3V
3.
SE
SE
T
ER
VI
PO
GN
RE
GN
A0
A1
TX
13
A
N
.
10
11
A
C
12
IN
A5
L
SC A
SD EF
AR ND
G 13
RX
A4
AL
O
A3
AN
A2
~
9
O
N
TX
RX
D 7
IG
6
IT ~
5
A
~
L
(P 4
W
3
M ~
~ 2
)
1
IS
p.10
Page 25
Page 26
A5
13
TX
RX
A4
A3
POWER
A2
A1
A0
VIN
GND
GND
5V
3.3V
RESET
IOREF
7-15V
Circuit 2: Potentiometer
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
RESET
7
~6
~5
4
~3
2
TX 1
RX 0
DIGITAL (PWM~)
ON
ISP
ANALOG IN
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
a b c d e
f g h i
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
Page 27
A0
Pin
5V13
GND
5V
GND
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
a8
a7
a6
j20
e8
e7
h20 h21
e6
Jumper Wire
j21
Image Reference:
330 Resistor
LED (5mm)
Potentiometer
Component:
0 volts
off
or
5 volts
on
HIGH
ANALOG
0 volts
to
1023
5 volts
But there are also a lot of things out there that aren't just "on" or "off".
Temperature levels, control knobs, etc. all have a continuous range of values
between HIGH and LOW. For these situations, the RedBoard offers six analog
inputs that translate an input voltage into a number that ranges from 0 (0 volts)
to 1023 (5 volts). The analog pins are perfect for measuring all those "real
world" values, and allow you to interface the RedBoard to all kinds of things.
DIGITAL
LOW
Many of the devices you'll interface to, such as LEDs and pushbuttons, have
only two possible states: on and off, or as they're known to the RedBoard,
"HIGH" (5 volts) and "LOW" (0 volts). The digital pins on an RedBoard are
great at getting these signals to and from the outside world, and can even do
tricks like simulated dimming (by blinking on and off really fast), and serial
communications (transferring data to another device by encoding it as patterns
of HIGH and LOW).
If you look closely at your RedBoard, you'll see some pins labeled "DIGITAL",
and some labeled "ANALOG". What's the difference?
Arduino Code:
Circuit 2
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 2
Code to Note:
int sensorValue;
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!
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);
delay(sensorValue);
The 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.
FF
RREE
I OI O S EETT
S
RREE VV
33
33..
RRE
ESS
EET
T
P
55VV D O W
D
GGNN D ER
D
GGNN
NN
VVII
A0
A1
LE
.S
IN
AR
E.
AC
88
O
N
TTXX
7
DD I 7 6
I GG
6
IITTA ~~ 5
A LL ~~5
((PP 44
WW M ~33
M~ ~ 2
~) 2
)
11
IS
P
K.
A5
AR
A4
RRXX
LL
SSCC A
A
SSDD E FF
E
AARR N DD
GG N 1 33
1
1122
1 11
~~ 1 00
1
~~ 1 99
~~
A3
11 3
RR1X3 3
T TX X
R XTXX
AN
AL
O
G
A2
00
Troubleshooting:
Sporadically Working
This is most likely due to a slightly dodgy connection
with the potentiometer's pins. This 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).
Page 28
Circuit 2
CIRCUIT
#3
RGB LED
PIN 11
PIN 10
RedBoard
PIN 9
Resistors (330 ohm)
(Orange-Orange-Brown)
RED
GREEN
BLUE
LED
(Light-Emitting Diode)
PARTS:
GND
(Ground)
LED
IC
Potentiometer
330 Transistor
LED
Wire
330
Resistor P2N2222AG Resistor
1
38
1X6
715
V
IO
F
RE
RE
5V
3V
3.
SE
SE
T
ER
VI
PO
RE
GN
GN
A0
A1
L
SC A
SD EF
AR ND
G 13
RX
TX
L
E
13
11
C
K
12
IN
A5
R
N
A4
AL
O
A3
AN
A2
10
~
9
D 7
I
6
IG T ~
AL ~5
(P 4
W
3
M ~
~ 2
IS
O
N
)
TX
RX
red
blue
green
common
p.10
Page 29
Page 30
A5
13
TX
RX
A4
A3
POWER
A2
A1
A0
VIN
GND
GND
5V
3.3V
RESET
IOREF
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
RESET
7
~6
~5
4
~3
2
TX 1
RX 0
DIGITAL (PWM~)
ON
ISP
ANALOG IN
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
a b c d e
f g h i
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
Page 31
5V
5V
Pin 9
330 Resistor
330 Resistor
Jumper Wire
Pin 10
Pin 11
5V
GND
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
e4 e1
g41
e7
5V
330 Resistor
h7
h6
e5
h4
e7 e1
g71
g61
e6
e7 e1
a4 a5 a6 a7
Image Reference:
Component:
LOW (0 volts)
HIGH (5 volts)
LOW (0 volts)
HIGH (5 volts)
LOW (0 volts)
HIGH (5 volts)
90%
50%
10%
10%
50%
90%
4.5V
2.5V
0.5V
The RedBoard is so fast that it can blink a pin on and off almost 1000 times
per second. PWM goes one step further by varying the amount of time that
the blinking pin spends HIGH vs. the time it spends LOW. If it spends most
of its time HIGH, a LED connected to that pin will appear bright. If it
spends most of its time LOW, the LED will look dim. Because the pin is
blinking much faster than your eye can detect, the RedBoard creates the
illusion of a "true" analog output.
The answer is no... and yes. The RedBoard does not have a true analog voltage
output. But, because the RedBoard is so fast, it can fake it using something
called PWM ("Pulse-Width Modulation"). The pins on the RedBoard with
~ next to them are PWM/Analog out compatible.
We've seen that the Arduino can read analog voltages (voltages between 0 and
5 volts) using the analogRead() function. Is there a way for the RedBoard to
output analog voltages as well?
Arduino Code:
Circuit 2
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 3
Code to Note:
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++").
if (x <= 255)
{}
else
{}
"If / else" statements are used to make choices in your programs. The statement
within the parenthesis () is evaluated; if it's true, the code within the first brackets {}
will run. If it's not true, the code within the second brackets {} will run.
delay(sensorValue);
V
15
7-
RE
SE
T
P
5V D O W
GN D E R
GN
N
VI
A0
A1
AR
LE
.S
IN
A5
L
SC A
SD EF
AR ND
G 13
A4
AR
E.
AC
K.
O
N
12
11
~ 0
1
~ 9
~
8
D 7
IG
6
IT ~
AL ~5
(P 4
W
3
M ~
~ 2
)
1
IS
P
TX
13
R1X3
T TX
RX X
A3
AN
AL
O
G
A2
RX
Troubleshooting:
Seeing Red
The 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);
Page 32
CIRCUIT #4
PIN 2
PIN 3
Multiple LEDs
RedBoard
PIN 4
PIN 5
LEDs
(Light-Emitting Diodes)
Resistors (330 ohm)
(Orange-Orange-Brown)
GND (Ground)
PIN 6
PIN 7
RedBoard
PIN 8
PIN 9
LEDs
(Light-Emitting Diodes)
PARTS:
GND (Ground)
LED
330
Resistor
X
Wire
10
715
V
IO
F
RE
RE
5V
3V
3.
SE
SE
T
ER
VI
PO
GN
RE
GN
A0
A1
TX
13
A
R
N
.
S
IN
A5
L
SC A
SD EF
AR ND
G 13
RX
L
E
A4
AL
O
A3
AN
A2
H
A
10
11
12
~
9
O
N
TX
RX
D 7
IG
6
IT ~
5
A
~
L
(P 4
W
3
M ~
~ 2
)
1
IS
Page 33
Page 34
A5
13
TX
RX
A4
A3
POWER
A2
A1
A0
VIN
GND
GND
5V
3.3V
RESET
IOREF
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
RESET
7
~6
~5
4
~3
2
TX 1
RX 0
DIGITAL (PWM~)
ON
ISP
ANALOG IN
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
a b c d e
f g h i
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
Page 35
a12
330 Resistor
a15
a9
+
-
c23 c24
c20 c21
c17 c18
c14 c15
c11 c12
330 Resistor
330 Resistor
c8 c9
c5 c6
c2 c3
a6
330 Resistor
a3
Image Reference:
330 Resistor
LED (5mm)
LED (5mm)
LED (5mm)
LED (5mm)
LED (5mm)
LED (5mm)
LED (5mm)
LED (5mm)
Component:
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
330 Resistor
330 Resistor
330 Resistor
Component:
Image Reference:
GND
5V
Pin 9
Pin 8
Pin 7
Pin 6
Pin 5
Pin 4
Pin 3
Pin 2
a18
e23
e20
e17
e14
e11
e8
e5
e2
a24
a21
a18
GND
Arduino Code:
Circuit 2
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 4
Code to Note:
int ledPins[] = {2,3,4,5,6,7,8,9};
digitalWrite(ledPins[0], HIGH);
index = random(8);
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. The
random() function is a great way to do this.
See http://arduino.cc/en/reference/random for more information.
3V
3.
F
RE
IO SET
RE
5V
PO
RE
SE
T
D W
GN D E R
GN
N
VI
A0
A1
A
LE
.S
IN
AR
H
K.
AC
IS
P
O
N
12
11
~ 0
1
~ 9
~
8
D 7
IG
6
IT ~
5
A
~
L
(P 4
W
3
M ~
~ 2
)
1
E.
A5
RN
A4
TX
L
SC A
SD EF
AR ND
G 13
RX
13
R1X3
T TX
RX X
AN
AL
O
3 G
A2
Troubleshooting:
Circuit 2
CIRCUIT
#5
Push Buttons
5 volt
PIN 13 RedBoard
PIN 3
LED
(Light-Emitting Diode)
PIN 2
Buttons
PARTS:
GND
(Ground)
IC Button
Push
LED
X
10K
330
Resistor
21
330
Wire
Resistor
18
28
19
Wire
X
715
V
IO
F
RE
RE
5V
3V
3.
SE
SE
T
ER
VI
PO
GN
RE
GN
A0
A1
TX
13
N
.
11
C
K
12
IN
A5
L
SC A
SD EF
AR ND
G 13
RX
L
A
R
A4
AL
O
A3
AN
A2
10
~
9
D 7
I
6
IG T ~
AL ~5
(P 4
W
3
M ~
~ 2
IS
O
N
)
TX
RX
Page 37
Page 38
A5
13
TX
RX
A4
A3
POWER
A2
A1
A0
VIN
GND
GND
5V
3.3V
RESET
IOREF
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
RESET
7
~6
~5
4
~3
2
TX 1
RX 0
DIGITAL (PWM~)
ON
ISP
ANALOG IN
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
a b c d e
f g h i
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
Page 39
d9 g9
5V
Jumper Wire
GND
Pin 13
Jumper Wire
Jumper Wire
Pin 3
Jumper Wire
j20
h11
h6
i9
Jumper Wire
Pin 2
i4
Jumper Wire
Jumper Wire
j21
330 Resistor
i11
h20 h21
d11 g11
10K Resistor
d4 g4
d6 g6
i6 a15
+
Image Reference:
10K Resistor
LED (5mm)
Push Button
Push Button
Component:
NOT
OR
!A is TRUE if A is FALSE.
!A is FALSE if A is TRUE.
...will turn on a heater if you're in heating mode AND the temperature is low, OR if you
turn on a manual override. Using these logic operators, you can program your RedBoard to
make intelligent decisions and take control of the world around it!
For example:
||
AND
DIFFERENCE
!=
&&
EQUIVALENCE
==
In order to make such decisions, the Arduino environment provides a set of logic operations
that let you build complex "if" statements. They include:
One of the things that makes the RedBoard so useful is that it can make complex decisions
based on the input it's getting. For example, you could make a thermostat that turns on a
heater if it gets too cold, a fan if it gets too hot, waters your plants if they get too dry, etc.
Arduino Code:
Circuit 2
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 5
Code to Note:
pinMode(button2Pin, INPUT);
button1State = digitalRead(button1Pin);
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)
F
RE
IO SET
RE V
3
3.
N
VI
RE
SE
T
P
5V D O W
GN D E R
GN
A0
A1
AR
LE
.S
IN
AC
K.
IS
P
O
N
12
11
~ 0
1
~ 9
~
8
D 7
IG
6
IT ~
5
A
~
L
(P 4
W
3
M ~
~ 2
)
1
H
E.
AR
A5
TX
L
SC A
SD EF
AR ND
G 13
A4
RX
13
R1X3
T TX
RX X
A3
AN
AL
O
G
A2
Troubleshooting:
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.
Page 40
Circuit 2
CIRCUIT
#6
Photo Resistor
5 volt
PIN 9
Photocell
(Light Sensitive Resistor)
LED
(Light-Emitting Diode)
PIN A0 RedBoard
Resistor (330 ohm)
(Orange-Orange-Brown)
PARTS:
GND
(Ground)
Photo Resistor
LED
X
330
Resistor
Wire
10K
Resistor
715
V
IO
F
RE
RE
5V
3V
3.
SE
SE
T
ER
VI
PO
GN
RE
GN
A0
A1
L
SC A
SD EF
AR ND
G 13
RX
TX
13
11
C
K
12
IN
A5
A4
AL
O
A3
AN
A2
10
~
9
O
N
TX
RX
D 7
IG
6
IT ~
5
A
~
L
(P 4
W
3
M ~
~ 2
)
1
IS
Page 41
Page 42
A5
13
13
RX
TX
TX
RX
A4
A3
POWER
A2
A1
A0
VIN
GND
GND
5V
3.3V
RESET
IOREF
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
RESET
7
~6
~5
4
~3
2
TX 1
RX 0
DIGITAL (PWM~)
ON
ISP
ISP
ANALOG IN
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
a b c d e
f g h i
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
Page
Page41
43
A0
Pin 9
5V
GND
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
j5
i5
j20
j6
j1
Jumper Wire
Jumper Wire
f6
h20 h21
i1
10K Resistor
f5
j21
Image Reference:
LED (5mm)
Photo Resistor
Component:
(ground) (-)
GND
PIN A0
3
Pin
Although the sensor's resistance will vary, the resistive sensors (flex sensor light
sensor, softpot, and trimpot) in the SIK are around 10K ohms. We usually want
the fixed resistor to be close to this value, so using a 10K resistor is a great choice
for the fixed "bottom" resistor. Please note the fixed resistor isn't necessarily the
bottom resistor. We do that with the photodiode only so that more
light = more voltage, but it could be flipped and we'd get the opposite response.
A voltage divider consists of two resistors. The "top" resistor is the sensor you'll
be using. The "bottom" one is a normal, fixed resistor. When you connect the
top resistor to 5 volts, and the bottom resistor to ground. The voltage at the
middle will be proportional to the bottom resistor relative to the total resistance
(top resistor + bottom resistor). When one of the resistors changes (as it will
when your sensor senses things), the output voltage will change as well!
5 volts
The RedBoard's analog input pins measure voltage, not resistance. But we can
easily use resistive sensors with the RedBoard by including them as part of a
"voltage divider".
Many of the sensors you'll use (potentiometers, photoresistors, etc.) are resistors
in disguise. Their resistance changes in proportion to whatever they're sensing
(light level, temperature, sound, etc.).
Arduino Code:
Circuit 2
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 6
Code to Note:
lightLevel = map(lightLevel, 0, 1023, 0, 255);
Parameters
map(value, fromLow, fromHigh, toLow, toHigh)
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
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
F
RE
IO SET
RE V
3
3.
N
VI
RE
SE
T
P
5V D O W
GN D E R
GN
A0
A1
N
AR
LE
IN
AR
K.
AC
H
IS
P
O
N
12
11
~ 0
1
~ 9
~
8
D 7
IG
6
IT ~
5
A
L ~ 4
(P
W
3
M ~
~ 2
)
1
E.
A5
.S
A4
TX
L
SC A
SD EF
AR ND
G 13
A3
RX
13
R1X3
T TX
RX X
AN
AL
O
G
A2
Troubleshooting:
Circuit 2
CIRCUIT
#7
Temperature Sensor
5 volt
TMP36
(Precision Temperature Sensor)
1
VCC
VOUT 2
PIN A0
GND
RedBoard
PARTS:
GND
(Ground)
Temp. Sensor
Wire
X
GND
SIGNAL
+V
FRONT
+V
SIGNAL
GND
BACK
715
V
IO
F
RE
RE
5V
3V
3.
SE
SE
T
ER
VI
PO
RE
GN
GN
A0
A1
L
SC A
SD EF
AR ND
G 13
RX
TX
13
.
R
IN
A5
A4
AL
O
A3
AN
A2
10
11
12
~
9
D 7
I
6
IG T ~
AL ~5
4
W
3
M ~
~ 2
IS
(P
O
N
)
TX
RX
p.44
Page 45
Page 46
A5
13
TX
RX
A4
A3
POWER
A2
A1
A0
VIN
GND
GND
5V
3.3V
RESET
IOREF
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
RESET
7
~6
~5
4
~3
2
TX 1
RX 0
DIGITAL (PWM~)
ON
ISP
ANALOG IN
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
a b c d e
f g h i
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
Page 47
GND
A0
Jumper Wire
GND
SIGNAL
+V
5V
Image Reference:
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Temperature Sensor
Component:
j7
j5
j6
V OUT +
f5 f6 f7
This circuit uses the Arduino IDE's serial monitor. To open this, first upload the
program then click the button which looks like a magnifying glass in a square. In
order for the serial monitor to operate correctly it must be set to the same baud
rate (speed in bits per second) as the code you're running. This code runs at 9600
baud; if the baud rate setting is not 9600, change it to 9600.
Arduino Code:
Circuit 2
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 7
Code to Note:
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(degreesC);
Serial.println(degreesF);
V
15
7-
F
RE
IO SET
RE V
3
3.
L
SC A
SD EF
AR ND
G 13
LE
AR
.S
AR
AC
K.
IS
P
O
N
12
11
~ 0
1
~ 9
~
8
D 7
IG
6
IT ~
5
A
~
L
(P 4
W
3
M ~
~ 2
)
1
E.
IN
A5
13
R1X3
T TX
RX X
A4
RX
RE
SE
T
A0
A1
AN
AL
O
G
A3
P
5V D O W
GN D E R
GN
N
VI
voltage: 0.73
voltage: 0.73
voltage: 0.73
voltage: 0.73
voltage: 0.73
voltage: 0.73
voltage: 0.73
voltage: 0.73
voltage: 0.73
voltage: 0.73
voltage: 0.73
voltage: 0.73
voltage: 0.73
voltage: 0.73
A2
Troubleshooting:
Gibberish is Displayed
This happens because the serial monitor is receiving data at
a different speed than expected. To fix 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 fingers to heat it up or
pressing a bag of ice against it to cool it down.
Page 48
Circuit 2
CIRCUIT
#8
A Single Servo
SIG
PIN 9
V+
RedBoard
GND
PARTS:
GND
(Ground)
Servo
Wire
X
715
V
IO
F
RE
RE
5V
3V
3.
SE
SE
T
ER
VI
PO
RE
GN
GN
A0
A1
L
SC A
SD EF
AR ND
G 13
RX
TX
13
.
R
IN
A5
A4
AL
O
A3
AN
A2
10
11
12
~
9
D 7
I
6
IG T ~
AL ~5
4
W
3
M ~
~ 2
IS
(P
O
N
)
TX
RX
Page 49
Page 50
A5
13
TX
RX
A4
A3
POWER
A2
A1
A0
VIN
GND
GND
5V
3.3V
RESET
IOREF
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
RESET
7
~6
~5
4
~3
2
TX 1
RX 0
DIGITAL (PWM~)
ON
ISP
ANALOG IN
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
a b c d e
f g h i
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
Page 51
5V
GND
Jumper Wire
a6
Jumper Wire
Jumper Wire
b5
Jumper Wire
e7
Jumper Wire
Pin 9
e6
Jumper Wire
Jumper Wire
e5
Jumper Wire
a7
e5 e6 e7
Image Reference:
Servo
Component:
Tools
Help
Verify / Compile
Edit Sketch
EEPROM
Ethernet
Firmata
LiquidCrystal
SD
Servo
SoftwareSerial
SPI
Stepper
Wire
After importing the library into your code, you will have access to a number of pre-written
commands and functions. More information on how to use the standard library functions
can be accessed at: http://arduino.cc/en/Reference/Libraries.
File
But anyone can create a library, and if you want to use a new sensor or output device,
chances are that someone out there has already written one that interfaces that device to the
RedBoard. Many of SparkFun's products come with Arduino libraries, and you can find
even more using Google and the Arduino Playground at http://arduino.cc/playground/.
When YOU get the RedBoard working with a new device, consider making a library for it
and sharing it with the world!
Libraries are collections of new commands that have been packaged together to make it easy
to include them in your sketches. Arduino comes with a handful of useful libraries, such as
the servo library used in this example, that can be used to interface to more advanced
devices (LCD displays, stepper motors, ethernet ports, etc.)
The Arduino development environment gives you a very useful set of built-in commands for
doing basic input and output, making decisions using logic, solving math problems, etc.
But the real power of Arduino is the huge community using it and their willingness to share
their work.
Arduino Code:
Circuit 2
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 8
Code to Note:
#include is a special "preprocessor" command that inserts a library (or any
other file) into your sketch. You can type this command yourself, or
choose an installed library from the "sketch / import library" menu.
#include <Servo.h>
Servo servo1;
servo1.attach(9);
servo1.write(180);
The servo library adds new commands that let you control a servo. To
prepare the Arduino to control a servo, you must first 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).
The servos in this kit don't spin all the way around, but they can be commanded
to move to a specific position. We use the servo library's write() command to
move a servo to a specified number of degrees(0 to 180). Remember that the
servo requires time to move, so give it a short delay() if necessary.
TX
8
D 7
IG
6
IT ~
AL ~5
P( W 4
3
M ~
~ 2
)
1
IS
P
Troubleshooting:
CIRCUIT #9
Flex Sensor
5 volt
SIG
PIN 9
V+
PIN A0
RedBoard
GND
Flex Sensor
PARTS:
GND
(Ground)
Flex
IC Sensor
Potentiometer
Servo
LED
33010K
Resistor
Resistor
11
X X
Wire
X
8 X1
11
715
V
IO
F
RE
RE
5V
3V
3.
SE
SE
T
ER
VI
PO
GN
RE
GN
A0
A1
TX
13
A
R
N
.
S
IN
A5
L
SC A
SD EF
AR ND
G 13
RX
A4
AL
O
A3
AN
A2
H
A
10
11
A
C
12
~
9
O
N
TX
RX
D 7
IG
6
IT ~
5
A
~
L
(P 4
W
3
M ~
~ 2
)
1
IS
Page 53
Page 54
A5
13
TX
RX
A4
A3
POWER
A2
A1
A0
VIN
GND
GND
5V
3.3V
RESET
IOREF
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
RESET
7
~6
~5
4
~3
2
TX 1
RX 0
DIGITAL (PWM~)
ON
ISP
ANALOG IN
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
a b c d e
f g h i
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
Page 55
e3
h19 h20
i20 i24
i19
Jumper Wire
Flex Sensor
10K Resistor
Jumper Wire
a3
Pin 9
5V
Jumper Wire
Jumper Wire
GND
a2 +
h24
Jumper Wire
Jumper Wire
b1 +
h24
Jumper Wire
h24 +
Jumper Wire
j20
e2
Jumper Wire
A0
e1
Jumper Wire
Jumper Wire
e1 e2 e3
Image Reference:
Servo
Component:
12345678
01234567
The key to visibility into a microcontroller is output. This can be almost anything,
including LEDs and buzzers, but one of the most useful tools is the serial monitor.
Using Serial.print() and println(), you can easily output human-readable text and
data from the RedBoard to a window back on the host computer. This is great for
your sketch's final output, but it's also incredibly useful for debugging.
It happens to everyone - you write a sketch which successfully compiles and uploads,
but you can't figure out why it's not doing what you want it to. Larger computers
have screens, keyboards, and mice that you can use to debug your code, but tiny
computers like the RedBoard have no such things.
Arduino Code:
Circuit 2
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 9
Code to Note:
F
RE
IO SET
RE V
3
3.
N
VI
RE
SE
T
P
5V D O W
GN D E R
GN
A0
A1
LE
.S
IN
AC
K.
IS
P
O
N
12
11
~ 0
1
~ 9
~
8
D 7
IG
6
IT ~
5
A
~
L
(P 4
W
3
M ~
~ 2
)
1
E.
AR
A5
AR
A4
TX
L
SC A
SD EF
AR ND
G 13
A3
RX
13
R1X3
T TX
RX X
AN
AL
O
G
A2
Troubleshooting:
Page 56
Circuit 2
CIRCUIT
#5
#10
Soft Potentiometer
RedBoard
PIN 11
PIN 10
5 volt
RedBoard
PIN 9
Resistors (330 ohm)
(Orange-Orange-Brown)
Soft Pot
PIN A0
RED
GREEN
BLUE
10
LED
(Light-Emitting Diode)
PARTS:
GND
(Ground)
LED
IC
330
LED
Soft Potentiometer
Resistor
X
330
Resistor
Wire
330
Resistor
318
10K
Resistor
715
V
IO
F
RE
RE
5V
3V
3.
SE
SE
T
ER
VI
PO
GN
RE
GN
A0
A1
TX
13
A
R
N
.
S
IN
A5
L
SC A
SD EF
AR ND
G 13
RX
A4
AL
O
A3
AN
A2
H
A
10
11
A
C
12
~
9
O
N
TX
RX
D 7
IG
6
IT ~
5
A
~
L
(P 4
W
3
M ~
~ 2
)
1
IS
Page 57
Page 58
A5
13
TX
RX
A4
A3
POWER
A2
A1
A0
VIN
GND
GND
5V
3.3V
RESET
IOREF
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
RESET
7
~6
~5
4
~3
2
TX 1
RX 0
DIGITAL (PWM~)
ON
ISP
ANALOG IN
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
a b c d e
f g h i
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
Page 59
5V
5V
330 Resistor
330 Resistor
Jumper Wire
Jumper Wire
A0
Pin 11
Jumper Wire
Jumper Wire
Pin 10
Jumper Wire
Jumper Wire
Jumper Wire
Pin 9
5V
330 Resistor
10K Resistor
5V
Image Reference:
Soft Potentiometer
Component:
j20
j19
j18
h7
h6
e5
h4
i19
g71
e7 e1
e6 e1
g61
e7
e4 e1
g41
e7
a4 a5 a6 a7
Jumper Wire
Jumper Wire
Component:
Image Reference:
GND
5V
10
Arduino Code:
Circuit 2
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 10
Code to Note:
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.
V
15
7-
3V
3.
F
RE
IO SET
RE
RE
SE
T
PO
5V
W
D
GN D E R
GN
N
VI
A0
A1
AR
LE
.S
IN
AC
K.
IS
P
O
N
12
11
~ 0
1
~ 9
~
8
D 7
IG
6
IT ~
AL ~5
(P 4
W
3
M ~
~ 2
)
1
E.
AR
A5
L
SC A
SD EF
AR ND
G 13
A4
TX
13
R1X3
T TX
RX X
A3
AN
AL
O
G
A2
RX
Troubleshooting:
Bizarre Results
The most likely cause of this is if youre pressing the
potentiometer in more than one position. This is normal
and can actually be used to create some neat results.
Page 60
Circuit 2
CIRCUIT
#11
Piezo Buzzer
11
Piezo Buzzer
RedBoard
PIN 9
PARTS:
GND
(Ground)
Piezo Buzzer
Wire
X
715
V
IO
F
RE
RE
5V
3V
3.
SE
SE
T
ER
VI
PO
GN
RE
GN
A0
A1
TX
N
.
G
R
H
A
IN
A5
13
A
R
LO
A4
L
SC A
SD EF
AR ND
G 13
RX
A3
AN
A2
H
A
12
10
11
~
9
O
N
TX
RX
D 7
IG
6
IT ~
5
A
~
L
(P 4
W
3
M ~
~ 2
)
1
IS
Page 61
Page 62
A5
13
TX
RX
A4
A3
POWER
A2
A1
A0
VIN
GND
GND
5V
3.3V
RESET
IOREF
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
RESET
7
~6
~5
4
~3
2
TX 1
RX 0
DIGITAL (PWM~)
ON
ISP
ANALOG IN
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
a b c d e
f g h i
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
Page 63
Pin 9
GND
Jumper Wire
Image Reference:
Jumper Wire
Jumper Wire
Piezo Buzzer
Component:
j9
+
i7
f7
f9
return(x);
When you write your own functions, you make your code neater and easier to re-use.
See http://arduino.cc/en/reference/functiondeclaration for more information
about functions.
If your function is returning a value from your function, put the type of the return
value in front of the function name. Then in your function, when you're ready to
return the value, put in a return(value) statement. If you won't be returning a value,
put "void" in front of the function name (similar to the declaration for the setup()
and loop() functions).
If you'll be passing parameters to your function, put them (and their types) in the
parentheses after the function name. If your function is not using any parameters, just
use an empty parenthesis () after the name.
Your functions can take in values ("parameters"), and return a value, as this one does.
x = parameter1 + parameter2;
Arduino contains a wealth of built-in functions that are useful for all kinds of things.
(See http://arduino.cc/en/reference for a list). But you can also easily create your
own functions. First, we need to declare a function. Here's a simple example named
"add," which adds two numbers together and returns the result. Let's break it down.
11
Arduino Code:
Circuit 2
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 11
Code to Note:
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 defined
between double-quotes (also called a "string"), OR as a list of
single-quoted characters.
F
RE
IO SET
RE V
3
3.
5V
PO
RE
SE
T
D W
GN D E R
GN
N
VI
A0
A1
LE
AR
.S
IN
AR
AC
K.
IS
P
O
N
12
11
~ 0
1
~ 9
~
8
D 7
IG
6
IT ~
5
A
~
L
(P 4
W
3
M ~
~ 2
)
1
E.
A5
TX
L
SC
A
SD EF
AR ND
G 13
A4
RX
13
R1X3
T TX
RX X
A3
AN
AL
O
G
A2
Troubleshooting:
No Sound
Given the size and shape of the piezo buzzer it is easy to
miss the right holes on the breadboard. Try double
checking its placement.
Page 64
12
Circuit 2
CIRCUIT
#12
Spinning a Motor
5 volt
Diode
(1N4148)
DC Motor
RedBoard
PIN 9
Transistor
(P2N2222AG)
Transistor
Diode
P2N2222AG
DC Motor
1N4148
Wire
X
330
Resistor
X
EMITTER
BASE
P2N2
222A
PARTS:
GND
(Ground)
COLLECTOR
FRONT
COLLECTOR
BASE
EMITTER
BACK
715
V
IO
F
RE
RE
5V
3V
3.
SE
SE
T
ER
VI
PO
RE
GN
GN
A0
A1
L
SC A
SD EF
AR ND
G 13
RX
TX
13
.
S
IN
A5
A4
AL
O
A3
AN
A2
H
A
10
K
.
11
12
R
E
~
9
D 7
I
6
IG T ~
AL ~5
(P 4
W
3
M ~
~ 2
IS
O
N
)
TX
RX
Page 65
Page 66
A5
13
TX
RX
A4
A3
POWER
A2
A1
A0
VIN
GND
GND
5V
3.3V
RESET
IOREF
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
RESET
7
~6
~5
4
~3
2
TX 1
RX 0
DIGITAL (PWM~)
ON
ISP
ANALOG IN
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
a b c d e
f g h i
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
Page 67
Image Reference:
e3 d11
+
5V
GND
Jumper Wire
Jumper Wire
Jumper Wire
j2
a7
Pin 9
e1
Jumper Wire
Jumper Wire
Jumper Wire
e2 e1
g21
e7
5V
330 Resistor
b11
a3
e7 e11
DC Motor
a1 a2 a3
GND
b7
EMITTER
BASE
COLLECTOR
Diode 1N4148
Transistor P2N2222AG
Component:
P2N2
222A
Finally, when you create something really cool, consider sharing it with the world so
that others can learn from your genius. Be sure to let us know on
https://www.sparkfun.com/project_calls so we can put it on our home page!
If you need help, there are internet forums where you can ask questions. Try
Arduino's forum at arduino.cc/forum, and SparkFun's at forum.sparkfun.com.
When you're ready to move to more advanced topics, take a look at Arduino's
tutorials page at arduino.cc/en/tutorial. Many of SparkFun's more advanced
products were programmed with Arduino, (allowing you to easily modify them), or
have Arduino examples for them. See our product pages for info.
It's usually pretty easy to pull pieces of different sketches together, just open them in
two windows, and copy and paste between them. This is one of the reasons we've
been promoting "good programming habits". Things like using constants for pin
numbers, and breaking your sketch into functions, make it much easier to re-use your
code in new sketches. For example, if you pull in two pieces of code that use the same
pin, you can easily change one of the constants to a new pin. (Don't forget that not
all of the pins support analogWrite(); the compatible pins are marked on your board.)
We've already shown you how to use a bunch of different input sensors and output
devices (and we still have a few more to go). Feel free to make use of the examples in
your own sketches - this is the whole idea behind the "Open Source" movement.
Most of the sketches you write will be a loop with some or all of these steps:
At this point you're probably starting to get your own ideas for circuits that do fun
things, or help solve a real problem. Excellent! Here are some tips on programming in
general.
12
Arduino Code:
Circuit 2
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 12
Code to Note:
The 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
"buffers" data coming into the port until you're ready to use it. The
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.
speed = Serial.parseInt();
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.
PO
W
E
D R
GN
N
VI
A0
L
SC A
SD EF
AR ND
G
13
AR
LE
.S
AR
E.
AC
K.
O
N
TX
12
11
~ 0
1
~ 9
~
8
D 7
I
6
IG T ~
AL ~5
(P 4
W
3
M ~
~ 2
)
1
IS
P
RX
13
R1X3
T TX
RX X
IN
A5
Page 68
A4
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.
AN
AL
O
3 G
A2
Troubleshooting:
A1
13
5
Circuit 2
CIRCUIT
#5
#13
Relays
5 volt
Resistor (330 ohm)
(Orange-Orange-Brown)
Diode
(1N4148)
SPDT Relay
Transistor
(P2N2222AG)
RedBoard
PIN 2
LEDs
(Light-Emitting Diodes)
PARTS:
GND
(Ground)
IC
Relay
Transistor
LED
Diode
P2N2222AG
X
330
Resistor
1N4148
LED
X
Wire
X
14
715
V
IO
F
RE
RE
5V
3V
3.
SE
SE
T
ER
VI
PO
RE
GN
GN
A0
A1
L
SC A
SD EF
AR ND
G 13
RX
TX
13
.
S
IN
A5
A4
AL
O
A3
AN
A2
H
R
10
K
.
11
12
~
9
D 7
I
6
IG T ~
AL ~5
(P 4
W
3
M ~
~ 2
IS
O
N
)
TX
RX
Page 69
Page 70
A5
13
TX
RX
A4
A3
POWER
A2
A1
A0
VIN
GND
GND
5V
3.3V
RESET
IOREF
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
RESET
7
~6
~5
4
~3
2
TX 1
RX 0
DIGITAL (PWM~)
ON
ISP
ANALOG IN
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
a b c d e
f g h i
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
Page 71
Image Reference:
Jumper Wire
i13 e22
i13
Jumper Wire
i15 e19
h9
j9
Jumper Wire
j3
j7
j5
Pin 2
e2
Jumper Wire
Jumper Wire
Jumper Wire
5V
330 Resistor
b14
+1
e7 e1
e3 e1
g31
e7
5V
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
+
f7
a3
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Component:
c22 c23
c19 c20
330 Resistor
a2 a3 a4
GND
e7
EMITTER
BASE
COLLECTOR
e14 e9
f15 f13 f9
Diode 1N4148
LED (5mm)
LED (5mm)
Transistor P2N2222AG
Relay
Component:
P2N2
222A
Image Reference:
GND
5V
e4 b9
a7 a9
a20 e19
+
b14
a23
+ e19
+
e15
+ e19
+
e15
f7
f5 f6e19
e15
13
Arduino Code:
Circuit 2
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 13
Code to Note:
digitalWrite(relayPin, HIGH);
digitalWrite(relayPin, LOW);
F
RE
IO SET
RE V
3
3.
RE
SE
T
P
5 V DD OW
GGNN DD E R
GGNN
NN
VVI
AA00
AA1
LE
.S
IINN
E.
K.
AC
IISS
PP
OO
NN
2
112
1
111
~~ 100
1
~~ 99
~~
88
DD I 77
I GG 66
IITT ~~ 5
AA 5
~
~
L
L
((PP 44
WW 33
MM ~~
~~ 22
))
11
AR
AA55
AR
AA44
CLL
SC A
DA
SSD EEFF
R
AAR NNDD
GG 1133
AA3
TTX
X
RX
1133
RRX1X3
TT T X
R XXX
AN
NA
ALL
OO
GG
AA2
00
Troubleshooting:
No Clicking Sound
The transistor or coil portion of the circuit isn't quite
working. Check the transistor is plugged in the right way.
Not Quite Working
The 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.
Page 72
14
Circuit 2
CIRCUIT
#14
Shift Register
RedBoard
5 volt
PIN 2
14
PIN 3
11
PIN 4
SER
VCC
SCK
QB
SCL
QC
16
15
QA
10
1
2
3
QD
12
RCK
QE
QF
13
8
OE
QG
GND
QH
QH*
6
7
9
LEDs
(Light-Emitting Diodes)
74HC595
PARTS:
GND
(Ground)
IC
LED
X
330
Resistor
Wire
19
VCC
QB
16
QC
15
QA
QD
14
SER
QE
13
OE
QF
12
RCLK
QG
11
SRCLK
QH
10
SRCLR
GND
QH
715
V
IO
F
RE
RE
5V
3V
3.
SE
SE
T
ER
VI
PO
RE
GN
GN
A0
A1
RX
13
IN
A5
L
SC A
SD EF
AR ND
G 13
TX
A4
AL
O
A3
AN
A2
12
~
~
11
10
~
9
D 7
I
6
IG T ~
AL ~5
(P 4
W
3
M ~
~ 2
IS
O
N
)
TX
RX
Page 73
Page 74
A5
13
TX
RX
A4
A3
POWER
A2
A1
A0
VIN
GND
GND
5V
3.3V
RESET
IOREF
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
RESET
7
~6
~5
4
~3
2
TX 1
RX 0
DIGITAL (PWM~)
ON
ISP
ANALOG IN
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
a b c d e
f g h i
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
Page 75
Jumper Wire
Jumper Wire
c24
a3
c24
a3
GND
j21
GND
j24
330 Resistor
330 Resistor
+
a3
Jumper Wire
c24
a3
GND
j18
330 Resistor
+
GND
Jumper Wire
c24
a3
GND
j15
330 Resistor
Jumper Wire
Jumper Wire
a24
a3
GND
c23
330 Resistor
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
a21
a3
h23 h24
h20 h21
h17 h18
Jumper Wire
GND
c23
h14 h15
Jumper Wire
330 Resistor
LED (5mm)
c23 c24
Jumper Wire
Jumper Wire
LED (5mm)
c20 c21
Jumper Wire
Jumper Wire
a18
a3
LED (5mm)
c17 c18
c14 c15
GND
c23
LED (5mm)
f8
330 Resistor
LED (5mm)
f7
Jumper Wire
LED (5mm)
f6
a15
a3
LED (5mm)
f5
Component:
330 Resistor
Image Reference:
LED (5mm)
IC
Component:
Image Reference:
GND
5V
Pin 3
Pin 4
Pin 2
a14
a3
+
a3
+
a3
a1
4
a3
a5
a3
a6
a3
a7
a3
a11
a3
a10
a3
a9
a3
a8
a3
+4
a1
a3
+
j10
a17
GND
a20
GND
a23
GND
f23
GND
f20
GND
f17
GND
f14
GND
j11
GND
j10
j9
j8
GND
j7
j6
GND
j5
GND
GND
+
14
Arduino Code:
Circuit 2
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 14
Code to Note:
You'll communicate with the shift register (and a lot of other parts) using an
interface called SPI, or Serial Peripheral Interface. This 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. The MSBFIRST parameter specifies the order
in which to send the individual bits, in this case we're sending the Most
Significant Bit first.
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 off. The RedBoard has several commands, such as
bitWrite(), that make this easy to do.
RE
SE
T
P
5V D O W
GN D E R
GN
N
VI
A0
A1
LE
.S
IN
AR
K
AC
IS
P
O
N
12
11
~ 0
1
~ 9
~
8
D 7
IG
6
IT ~
AL ~5
(P 4
W
3
M ~
~ 2
)
1
E.
A5
AR
A4
TX
L
SC A
SD EF
AR ND
G 13
A3
RX
13
R1X3
T TX
RX X
AN
AL
O
G
A2
Troubleshooting:
Circuit 2
CIRCUIT
#5
#15
LCD
GND
(Ground)
PARTS:
RedBoard
DB7
DB6
DB5
DB4
DB3
DB2
DB1
DB0
R/W
RS
VO
VDD
VSS
16x2 LCD
5 volt
15
IC
LCD
LED
Potentiometer
330 Wire
Resistor
XX
Wire
16
8
19
V
15
7-
F
RE
IO SET
RE V
3
3.
RE
SE
T
P
5V D O W
GN D E R
GN
N
VI
A0
A1
IN
A5
L
SC A
SD EF
AR ND
G 13
A
R
A4
1
13
RX 3
T TX
R XX
L
E
A3
AN
AL
O
G
A2
O
N
TX
X
RRX
12
11
~ 0
1
~ 9
~
8
D 7
IG
6
IT ~
5
A
~
L
(P 4
W
3
M ~
~ 2
)
1
IS
P
Page 77
Page 78
A5
13
TX
RX
A4
A3
POWER
A2
A1
A0
VIN
GND
GND
5V
3.3V
RESET
IOREF
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
RESET
7
~6
~5
4
~3
2
TX 1
RX 0
DIGITAL (PWM~)
ON
ISP
ANALOG IN
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
a b c d e
f g h i
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
Page 79
f16
GND
Jumper Wire
+
a3
a3
a3
f28
a3
f17
j10
f15
GND
Jumper Wire
Pin 2
e8
GND
Jumper Wire
Jumper Wire
e7
GND
Jumper Wire
+
a3
+
j10
b6
b7
b8
j15
j16
j17
j18
j19
j20
j21
j22
j23
j24
j25
j26
j27
j28
e6
GND
GND
Jumper Wire
j30
j29
Jumper Wire
5V
Image Reference:
Jumper Wire
Potentiometer
LCD
Component:
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Component:
Image Reference:
Pin 12
Pin 11
Pin 5
Pin 4
Pin 3
a3
+
a3
f30 a3
f29
GND
f27
f26
GND
f25
f20
f19
f18
15
Arduino Code:
Circuit 2
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 15
Code to Note:
#include <LiquidCrystal.h>
This 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!
lcd.print(hello, world!);
This is the first time youll fire 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!
RE
SE
T
P
5V D O W
GN D E R
GN
N
VI
A0
A1
LE
.S
IN
AR
AC
K.
IS
P
O
N
12
11
~ 0
1
~ 9
~
8
D 7
IG
6
IT ~
5
A
~
L
(P 4
W
3
M ~
~ 2
)
1
E.
A5
AR
A4
TX
L
SC A
SD EF
AR ND
G 13
A3
RX
13
R1X3
T TX
RX X
AN
AL
O
G
A2
Troubleshooting:
Page 80
16
Circuit 2
CIRCUIT
#5
#16
Simon Says
Piezo Buzzer
RedBoard
PIN 7
PIN 4
LEDs
(Light-Emitting Diodes)
PIN 5
Yellow
PIN 13
Blue
PIN 3
Green
PIN 10
Buttons
Red
PIN 6
PIN 12
GND
(Ground)
PIN 2
PIN 9
PARTS:
GND
(Ground)
IC
330
Resistor
Push Button
330
Wire
Resistor
LED
X
14
419
Wire
Piezo Element
X X
16
715
V
IO
F
RE
RE
5V
3V
3.
SE
SE
T
ER
VI
PO
GN
RE
GN
A0
A1
TX
13
N
.
A
IN
A5
L
SC
A
SD EF
AR ND
G 13
RX
L
E
R
A4
AL
A3
AN
A2
10
11
12
~
9
O
N
TX
RX
D 7
IG
6
IT ~
5
A
L ~ 4
(P
W
3
M ~
~ 2
)
1
IS
Page 81
Page 82
A5
13
TX
RX
A4
A3
POWER
A2
A1
A0
VIN
GND
GND
5V
3.3V
RESET
IOREF
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
RESET
7
~6
~5
4
~3
2
TX 1
RX 0
DIGITAL (PWM~)
ON
ISP
ANALOG IN
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
a b c d e
f g h i
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
Page 83
Piezo Element
Push Button
Push Button
Push Button
Push Button
LED (5mm)
LED (5mm)
LED (5mm)
e20
GND
330 Resistor
g20
a3
g18
a3
g13
a3
g11
a3
a16 a14
d29 g29
d27 g27
d24 g24
d22 g22
d9 g9
d7 g7
d4 g4
d2 g2
j20 c3
j18 c3
j12 c3
j11 c3
e18
GND
330 Resistor
e12
GND
330 Resistor
LED (5mm)
e11
GND
Image Reference:
330 Resistor
Component:
Pin 13
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
GND
Pin 9
GND
a3
c29
j10
c27 a3
c24
j10
Jumper Wire
d20
j10
d18
j10
d12
j10
c22 a3
Pin 2
Pin 10
Pin 3
Pin 13
d11
j10
d12
j10
d11
j10
c9
j10
c7 a3
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Pin 5
Pin 5
Jumper Wire
Jumper Wire
Pin 12
Jumper Wire
Jumper Wire
c4
j10
Jumper Wire
Pin 6
c2 a3
Image Reference:
Jumper Wire
Component:
16
Arduino Code:
Circuit 2
Open Arduino IDE // File > Examples > SIK Guide > Circuit #16
Code to Note:
#define
byte
The #define statement is used to create constants in your code. Constants are variables that
will likely only have one value during the lifespan of your code. Thus, you can assign
constants a value, and then use them throughout your code wherever you need them.
Then, if you need to change that value, you only have to change one line instead of going
through all the code to find every instance of that variable.
Bytes are another variable type. In the world of computing, a byte is a chunk of space that
contains 8 bits, and a bit is a single binary value. Binary is another way of counting and uses
only 1's and 0's. So a byte can hold all 1's: 11111111, all 0's: 00000000, or a combination of
the two: 10010110.
LE
.S
IN
AR
AC
K.
IS
P
O
N
12
11
~ 0
1
~ 9
~
8
D 7
IG
6
IT ~
5
A
~
L
(P 4
W
3
M ~
~ 2
)
1
E.
A5
AR
A4
TX
L
SC
A
SD EF
AR ND
G 13
A3
RX
13
R1X3
T TX
RX X
AN
AL
O
G
A2
Troubleshooting:
No sound
Once the buzzer is in the breadboard, it's hard to see the legs and
which row they are connected to. If you aren't hearing any sound,
make sure your wires are on the same row as the buzzer legs.
Game is not working
If everything starts up ok, but you're having trouble when it comes
time to play the game, you may have a button or two misplaced.
Pay close attention to which pin is connected to each button, as it
matters which button is pressed when a particular color lights up.
Page 84
Learning More
Visit us Online:
This 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!
www.sparkfun.com
NOTES:
KIT INCLUDES
SparkFun RedBoard
Breadboard
Instruction booklet
Sealed relay
Small servo
LEDs
RGB LED
Temperature sensor
DC motor
8-bit shift register
Push button switches
Potentiometer
Photo Resistor
Transistors
Jumper wires
USB cable
Signal diodes
10k ohm resistors
SparkFun Electronics, inc. All rights reserved. The SparkFun Inventors kit for the SparkFun RedBoard features, specifications, 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.