Sik Guide: Your Guide To The Sparkfun Inventor'S Kit For The Sparkfun Redboard
Sik Guide: Your Guide To The Sparkfun Inventor'S Kit For The Sparkfun Redboard
15V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A2
A5 ANALOG SDASCL
XT
A3 AREF
A4 XR13
GND
IN
13
12
~11
~10
~9
ISP LDIGITA 8
~6
7
ON
)(PWM~ 4
~5
~3
RX 1 2
TX
0
SIK GUIDE
Your guide to the SparkFun Inventor’s Kit for the SparkFun RedBoard
X
TX 7
~6
DIGITAL ~5 4
(PWM
ARDUINO
LANGUAGE
V
DEVELOPMENT
PLATFORM
Version 3.0
RE F T
Table of Contents
www.sparkfun.com
Section 1: Getting Started
Install Drivers 4
Inventory of Parts 11
RedBoard 13
Breadboard 15
Circuit #2 - Potentiometer 24
www.sparkfun.com
RedBoard
// SparkFun RedBoard
RESET
AREF
IOREF 13
RESET 12
3.3V ~11
5V ~10
POWE
GND ~9
VIN
R
GND 8
DIGIT
AL
7
~6
A0
~5
ANALOG
(PW
M~)
A1
X
R
X
T
4
A2
~3
A3
2
A4
TX 1
IN
A5
RX 0
P
S
I
N
O
c
b
d
h
W
E internet-capable computer, open up your favorite browser and
SW
S type in the following URL into the address bar:
arduino.cc/en/main/software
1 DownloadWindows
computer
Clickonyour appropriate
Mac OSWindowsX
Mac OS X
Linux:
Linux: 3232 bit,bit,64bit64 bit
source
user
•••••••••
Choose the appropriate Operating System installation package for your computer.
// Connect your RedBoard to your Computer
Use the USB cable provided in the SIK kit to connect the
RedBoard to one of your computer’s USB inputs.
7 -
15V
IOREF
3. RESET
5V 3V
GND
VIN POWER RESET
GND
A0
A1
A2
A3 XT SDASCL
A4 AREF
A5 ANALOG XR13 GND
2
IN
13
12
~11
~10
ISP
~9
LDIGITA 8
7
ON
)(PWM~ 4 ~6
~5
~3
RX TX
1 2
0
1 2 3 4 5 6
9
GUI (Graphical User Interface)
1 Verify: Compiles and approves your code. It will catch errors in syntax (like missing semi-colons or parenthesis). // See Diagram Below
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
4 Open: This button will let you open up an existing sketch. // See Diagram Below
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
// Select your board: Arduino Uno
Tools Help
Auto Format
Archive Sketch
Fix Encoding & Reload
Serial Monitor
Board
Serial Port com 1
com 12
Select the serial device of the RedBoard from the Programmer
Tools | Serial Port menu. is is likely to be com3 or Burn Bootloader
higher (COM1 and COM2 are usually reserved for
hardware serial ports). To nd out, you can disconnect
your RedBoard and re-open the menu; the entry that
Device
Tools Help
Auto Format
Archive Sketch
Fix Encoding & Reload
Serial Monitor
Board
Serial Port /dev/tty.usbmodem262471
/dev/cu.usbmodem262471
Select the serial device of the RedBoard from the Tools Programmer /dev/tty.Bluetooth-Modem
Burn Bootloader /dev/cu.Bluetooth-Modem
> Serial Port menu. On the Mac, this should
/dev/tty.FireFly-7256-SPP
be something with /dev/tty.usbmodem or /dev/cu.FireFly-7256-SPP
/dev/tty.usbserial in it. /dev/tty.tiPhone-WirelessiAP-1
/dev/cu.tiPhone-WirelessiAP-1
/dev/tty.Bluetooth-PDA-Sync
/dev/cu.Bluetooth-PDA-Sync
http://www.arduino.cc/playground/Learning/Linux
Download Arduino Code (For use with the circuits in this guide)
5
Type in the following URL to download the code:
sparkfun.com/sikcode
library in Arduino folder
Contents
Copy “SIK Guide Code” into “Examples”
Resources
Find “Arduino” in your
applications folder. Right click(ctrl
Java
+ click) on “Arduino”. Select
Unzip the le “SIK Guide Code”. It “Show Package Contents”.
should be loacted in your browser’s examples
“Downloads” folder. Right click the Arduino
Open
zipped folder and choose “unzip”. Copy the “SIK Guide Code” folder into
Show Package Contents
Move to Trash Arduino’s folder named “examples”.
http://www.arduino.cc/playground/Learning/Linux
//
WHAT’S NEXT? Read on to learn more about getting started with circuits. en you can start on your rst circuit on
page 17!
Getting Started with Circuits
abcde f g h i
// Simple and Complex Circuits 1 1
2 2
3 3
In this guide, you will be primarily exploring 4 4
5 5
simple circuits - but that doesn't mean you can't do 6 6
7 7
amazing things with simple tools! When you've 8 8
9 9
nished the SIK, your knowledge of circuits will 10 10
11 11
enable you to explore amazing projects and unleash 12 12
13 13
the power of your imagination. 14 14
15 15
16 16
17 17
18 18
19 19
20 20
21 21
22 22
23 23
24 24
25 25
26 26
27 27
28 28
29 29
30 30
abcde f g h i
Inventory of Parts
Potentiometer Diode
(1N4148)
* ACTUAL SIZE
x1 x2
x1
FRONT FRONT
BACK BACK
x1 x2
x1 x2
Flex Sensor SparkFun RedBoard
RESET
x1 7-15V
SCL
SDA
Soft Potentiometer AREF
GND
13
IOREF
12
RESET
~11
3.3V
~10
5V
~9
POWE
GND
DIGITAL
VIN
8
R
GND
7
~6
3
1
X
R
X
T
(PWM~
A0 ~5
A1
ANAL
4
)
OG
A4
A2 ~3
x1 A3 2
TX 1
IN
A5 RX 0
ISP
Servo N
O
x1
Breadboard
Standard Solderless (Color may vary)
x1
abcde f g h i
1 1
LCD 20
21
20
21
22 22
23 23
24 24
25 25
26 26
27 27
28 28
29 29
30 30
abcde f g h i
x1 x1
RE
SE
T
2
1
8
7-15V
SCL
SDA
AREF
4 3 5
GND
13
IOREF
12
RESET
~11
3
1
X
R
X
T
3.3V
~10
5V
~9
GND
POW
10 8 6
ER
VIN
DIGITAL
GND
7
~6
(PWM~
A0 ~5
A1 4
ANAL
)
OG
A4
A2 ~3
A3 7 2
ON
TX 1
9
0
IN
A5 RX
ISP
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.
3 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.
LED (TX: Transmitting) - This shows when the FTDI chip is transmitting data bits to the microcontroller. This
4 happens when the microcontroller is receiving this data from the computer.
5 LED (Pin 13: Troubleshooting) - 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
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
// 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
Ground
11 RFU
Digital
IOREF
Digital
Reset
Digital
Power Out
Digital
Power Out
Digital
Ground
Digital 6
Ground
10 Power In Digital
Digital
Analog Digital
Analog Digital
Analog Digital
Analog Digital
Analog TX - Out
Analog RX - In
abcde f g h i
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
20 20
21 21
22 22
23 23
24 24
25 25
26 26
27 27
28 28
29 29
30 30
abcde f g h i
This line divides the board in half, restricting electricity to one half or the other.
Breadboard
1 Vertical Connection (+ Power and - Ground) - Power bus // See Diagram Below
Making a Connection:
2 Horizontal Connection (a-e & f-j) // See Diagram Below) Above the breadboard
LED
abcde f gh i
1
1
Power:
2
3
Each + sign runs power anywhere
4
4
in the vertical column.
5
Ground:
6
8
8
Each - sign runs to ground anywhere Inside the breadboard
10
10
11
11
12
12
Horizontal Rows:
13
14
14
15
comprised of five horizontal sockets.
15
16
Components placed in the same row will be
16
17
connected in a circuit when power is running.
17
18
18
19
19
20
20
21
21
22
22
23
23
24
24
25
25
26
26
27
27
28
28
29
29
30 30
abcde f gh i
View of the inside
CIRCUIT #1 - Your First Circuit
How It Works:
2 2
T
E
S
E
R
3 3
5 5
T
E
S
E
R
4 4
6 6
7-15V 7 7
7-15V 8 8
9 9
SCL
SCL 10 10
SDA 11 11
SDA
AREF 12 12
AREF
GND 13 13
GND
13 14 14
IOREF
13
13
IOREF 12 15 15
RESET 12
3
1
RESET ~11 16 16
3. 3 V ~11
17 17
X
X
R
R
X
T
X
T
3. 3 V ~10
A0 DIGITAL ~5
GN D ~9 19 19
GN D 8
GN D 8 20 20
VIN 7
VIN ~6 7 21 21
~6 22 22
(PWM~
A 1A 0 ~5 4 23 23
A3 2 26 26
)
A 2 A1 ~3 4 24 24
INA NA L
OG
A5 RX 0 28 28
A2 ~3 25 25
P
S
I
12
N
O
A 4 A3 TX
A 5 A4 RX T X 0
1 27 27
IN
N
O
29 29
30 30
P
S
I
a bc de f g h i
7-
15V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A2 SCL
A5 ANALOG XT SDA
13 AREF
A4 A3
XR GND
IN
12 13
~11
~10
~9
8
ISP LDIGITA
7
~6
)(PWM~4
ON
~3 ~5
TX 2
RX 1
0
Your RedBoard runs on 5V. is 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 can’t hurt you, so
don’t be afraid to touch anything in your circuit. You can also power the RedBoard through the barrel
jack. e on-board voltage regulator can handle anything from 7 to 15VDC.
PIN 13 RedBoard Blinking an LED
1
LED LEDs (light-emitting diodes) are small, powerful lights
(Light-Emitting Diode) that are used in many di erent applications. To start o
the SIK, we will work on blinking an LED. at's right
- it's as simple as turning a light on and o . It might
not seem like much, but establishing this important
baseline will give you a solid foundation as we work
Resistor (330 ohm) toward more complex experiments.
(Orange-Orange-Brown)
Resistor
X 1 X 1 X 3 This section lists the parts you
will need to complete the circuit.
7
-
15V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A5
A2
ANALOG
SCL
A4 A3 XT
XR AREF
IN GND
13
12 13
~11
~10
~9
ISP LDIGITA 8
7
~6
)(PWM~ 4
ON ~5
~3
TX
1 2
RX
0
7-15V
IOREF
RESET
3.3V
5V
GND
POW
ER
VIN
GND
ANALOG
A1
A4
A2
A3
IN
A5
0
Component: Image Reference: 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
+ c2 c3 the component’s markings indicating how to place it on the breadboard.
LED (5mm) -
-
Resistors are placed in breadboard sockets only. The “-” symbol represents any socket in its vertical
330 Resistor a3 a3 column on the Power bus.
Jumper Wire GND “GND” on the RedBoard should be connected to the row marked “-” on the breadboard.
Jumper Wire 5V + “5V” on the RedBoard connects to the row marked “+” on the breadboard.
Jumper Wire Pin 13 e2 “Pin 13” on the RedBoard connects to socket “e2” on the breadboard.
// Circuit #1
Circuit #1
/*Blink
*/
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
is sends the instructions via the USB cable to the computer chip on the RedBoard. e
Upload
RedBoard will then begin running your code automatically.
// The result of a completed circuit with correct code after verified and uploaded.
7
-
15V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A2
A3 XT SCL
A4 XR
SDA
A5 ANALOG 13
IN
GND
12 13
~11
~10
ISP ~9
LDIGITA 8
7
ON ~6
)(PWM~ ~5
~3
4
RX
TX
1 2
0
This is where you will find the
1 Circuit2 Arduino codeArduinoforeachcircuitCode:.
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 1
Code to Note: Remember to Verify and
Upload your code.
Begin to understand how the
Arduino code works. See below.
Before you can use one of the RedBoard's pins, you need to tell the
pinMode(13, OUTPUT); RedBoard whether it is an INPUT or OUTPUT. We use a
built-in "function" called pinMode() to do this.
digitalWrite(13, HIGH); When you're using a pin as an OUTPUT, you can command it to be
HIGH (output 5 volts), or LOW (output 0 volts).
15V
IOREF
3. RESET
5V 3V
GND
VIN POWER RESET
GND
A0
A1
A2
A5 ANALOG
A4 A3
IN
ISP
LED Not Lighting Up? Almost all modern at screen televisions and monitors
LEDs will only work in one direction. Try taking it out and have LED indicator lights to show they are on or o .
twisting it 180 degrees (no need to worry, installing it
backward does no permanent harm).
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: [email protected]
2
CIRCUIT #2
Potentiometer
PIN 13 RedBoard
In this circuit you’ll work with a potentiometer.
5 volt A potentiometer is also known as a variable resistor.
LED When it’s connected with 5 volts across its two outer
(Light-Emitting Diode) 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
Potentiometer PIN A0 demonstration of a variable voltage divider circuit.
RedBoard e voltage is divided proportionate to the resistance
Resistor (330 ohm) between the middle pin and the ground pin. In this
(Orange-Orange-Brown)
circuit, you’ll learn how to use a potentiometer to
control the brightness of an LED.
GND
(Ground)
Resistor
X 1 X 18 X 18 X196
7
-
15V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A2
A5 ANALOG XR
SCL
A4 A3 XT SDA
AREF
IN 13 GND
12 13
~11
~10
~9
ISP LDIGITA 8
7
~6
)(PWM~ 4
ON
~3 ~5
TX
1 2
RX
0
p.2410
Circuit 2: Potentiometer
7-15V
IOREF
RESET
3.3V
5V
POWE
GND
VIN
R
GND
ANALOG
A1
A4
A2
A3
IN
A5
0
Component: Image Reference: Digital versus Analog:
a6
Potentiometer a7
a8
If you look closely at your RedBoard, you'll see some pins labeled
"DIGITAL", and some labeled "ANALOG". What's the erence?di
LED (5mm) + h20 h21
-
- Many of the devices you'll interface to, such as LEDs and pushbuttons,
have only two possible states: on and ,o or as they're known to the
330 Resistor j21 RedBoard, "HIGH" (5 volts) and "LOW" (0 volts). e digital pins on an
RedBoard are great at getting these signals to and from the outside
6 world, and can even do tricks like simulated dimming (by blinking on
Jumper Wire e and o really fast), and serial communications (transferring data to
another device by encoding it as patterns of HIGH and LOW).
inV3
DIGITAL off or on
Jumper Wire e
Jumper Wire P51 j20 0 volts 5 volts
But there are also a lot of things out there that aren't just "on" or ""o.
Jumper Wire GND5V + Temperature levels, control knobs, etc. all have a continuous range of values
Jumper Wire GND between HIGH and LOW. For these situations, the RedBoard erso six analog
inputs that translate an input voltage into a number that ranges from 0 (0 volts)
to 1023 (5 volts). e analog pins are perfect for measuring all those "real world"
values, and allow you to interface the RedBoard to all kinds of things.
0 volts 5 volts
ANALOG to
0 1023
2 Circuit
Arduino Code:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 2
Code to Note:
sensorValue = analogRead(sensorPin); pin. analogRead() takes one parameter, the analog pin you want to
delay(sensorValue); 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.
15V
You should see the LED blink faster
or slower in accordance with your IOREF
3. RESET
5V 3V
potentiometer. If it isn't working, GND
POWER
VIN GND
make sure you have assembled the
RESET
A0
A1
A2
circuit correctly and veri ed and A5
A4 A3
ANALOG
XT
SCL
SDA
XR
AREF
uploaded the code to your board or IN
13
13
12
~11
see the troubleshooting tips below. ~10
~9
ISP LDIGITA 8
~6
7
)(PWM~ 4
ON
~3 ~5
TX
1 2
RX
0
Not Working
Make sure you haven’t 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).
PIN 11
RGB LED 3
PIN 10 RedBoard You know what’s even more fun than a blinking
LED? Changing colors with one LED. RGB, or
PIN 9 red-green-blue, LEDs have three di erent color-
emit-ting diodes that can be combined to create all
Resistors (330 ohm) sorts of colors. In this circuit, you’ll learn how to
(Orange-Orange-Brown) use an RGB LED to create unique color
combinations. Depending on how bright each diode
is, nearly any color is possible!
LED
GREE
BLUE
RED
(Light-Emitting Diode)
N
GND
(Ground)
LEDPotentiometerIC330LE
PARTS:
D 330Wire
Resistor
X 1 X 1 X 3 X 1X6 X 8
7
-
15V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A2
A5 ANALOG
SCL
A4 A3 XT
XR AREF
IN GND
13
12 13
~11
~10
~9
ISP LDIGITA 8
7
)(PWM~ 4 ~6
ON ~5
~3
TX
1 2
RX
0
r ed
blu e
common
green
p.2810
Circuit 3: RGB LED
7-15V
IOREF
RESET
3.3V
5V
POWE
GND
VIN
R
GND
ANALOG
A1
A4
A2
A3
IN
A5
0
Component: Image Reference: The shocking truth behind analogWrite():
a4 a5a6 a7
RGB LED (5mm) 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?
330 Resistor 5V e4 g4
e answer is no... and yes. e RedBoard does not have a true analog voltage
5V g6
output. But, because the RedBoard is so fast, it can fake it using something
330 Resistor e6
called PWM ("Pulse-Width Modulation"). e pins on the RedBoard with
“~” next to them are PWM/Analog out compatible.
330 Resistor e7 g7
e RedBoard is so fast that it can blink a pin on and o almost 1000 times
per second. PWM goes one step further by varying the amount of time
Jumper Wire Pin 9 5h4 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
Jumper Wire e creates the illusion of a "true" analog output.
Jumper Wire Pin 10 h6
HIGH (5 volts)
Jumper Wire Pin 11 h7 90% 0.5V
LOW (0 volts)
10%
Jumper Wire 5V +
HIGH (5 volts)
Jumper Wire GND
50%
LOW (0 volts) 2.5V
50%
10%
HI GH (5 vol ts )
3
Code to Note:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 3
if (x <= 255) "If / else" statements are used to make choices in your programs. e statement
{} within the parenthesis () is evaluated; if it's true, the code within the rst brackets
else {} will run. If it's not true, the code within the second brackets {} will run.
{}
delay(sensorValue); 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.
3
5V 3V
GND
POWER
A0
A1
A2
A5 ANALOG
XT
SCL
A4 A3
XR AREF
IN 13 GND
12 13
~11
~10
~9
ISP LDIGITA 8
~6 7
ON )(PWM~ ~5
~3 4
TX
1 2
RX
analogWrite(RED_PIN, redIntensity);
to
analogWrite(RED_PIN, redIntensity/3);
CIRCUIT #4
PIN 2
PIN 3
PIN 7
Resistor
X 8 X 8 X 10
7
-
15V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A2
A5 ANALOG
SCL
A4 A3
13
AREF
IN GND
12 13
~11
~10
~9
ISP LDIGITA 8
~6 7
)(PWM~ 4
ON
~3 ~5
TX
1 2
RX
0
p.32
Circuit 4: Multiple LEDs
7-15V
IOREF
RESET
3.3V
5V
POWE
GND
VIN
R
GND
ANALOG
A1
A4
A2
A3
IN
A5
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
f gh i 25
26
2 27
3 28
4
29
5
30
6
f gh i
7
8
0
Component: Image Reference: Component: Image Reference:
int ledPins[] = {2,3,4,5,6,7,8,9}; a handy way to group them together. Here we're creating
Computers like to do the same things each time they run. But sometimes
index = random(8); you want to do things randomly, such as simulating the roll of a
dice. e random() function is a great way to do this.
See http://arduino.cc/en/reference/random for more information.
15V
instead of one LED, you should see all the
LEDs blink. If they aren't, make sure you IOREF
3. RESET
5V 3V
GND
GND
RESET
A2
A5 SCL
or see the troubleshooting tips below.
ANALOG
A4 A3 XT
XR AREF
IN
13 13
12
~11
~10
~9
ISP LDIGITA 8
)(PWM~4 ~6 7
ON
~3 ~5
TX
1 2
RX
0
Some LEDs Fail to Light Scrolling marquee displays are generally used to spread
It is easy to insert an LED backwards. Check the LEDs short segments of important information. ey are built
that aren't working and ensure they the right way out of many LEDs.
around.
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.
5
CIRCUIT #5
Push Buttons
5 volt
Up until now, we’ve focused solely on outputs.
Now we’re going to go to the other end of spectrum
Resistors (10K ohm) and play around with inputs. In this circuit, we’ll be
(Brown-Black-Orange) looking at one of the most common and simple
PIN 13 RedBoard inputs – a push button. e way a push button works
LED
PIN 3
PIN 2 with RedBoard is that when the button is pushed,
(Light-Emitting Diode)
the voltage goes LOW. e RedBoard reads this and
Buttons
reacts accordingly. In this circuit, you will also use
a pull-up resistor, which keeps the voltage HIGH
Resistors (330 ohm)
(Orange-Orange-Brown) when you're not pressing the button.
GND
(Ground)
Resistor Resistor
X 21 X 18 X 28 X 1 X 7
7 -
1
5
V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A2
A5 ANALOG
SCL
A4 A3 XT
XR AREF
IN 13 GND
12 13
~11
~10
~9
ISP LDIGITA 8
~6 7
)(PWM~ 4
ON ~5
~3
1
TX 2
RX
0
p.3610
Circuit 5: Push Buttons
7-15V
IOREF
RESET
3.3V
5V
POWE
GND
VIN
R
GND
ANALOG
A1
A4
A2
A3
IN
A5
0
Component: Image Reference: How to use logic like a Vulcan:
d4 g4
Push Button One of the things that makes the RedBoard so useful is that it can make complex decisions
d6 g6
based on the input it's getting. For example, you could make a thermostat that turns on a
d9 g9 heater if it gets too cold, a fan if it gets too hot, waters your plants if they get too dry, etc.
Push Button
d11 g11
In order to make such decisions, the Arduino environment provides a set of logic
operations that let you build complex "if" statements. ey include:
LED (5mm) - + h20 h21
-
4 == EQUIVALENCE A == B is true if A and B are the SAME.
10K Resistor i6 +
!= DIFFERENCE A != B is true if A and B are NOT THE SAME.
10K Resistor i11 +
&& AND A && B is true if BOTH A and B are TRUE.
Jumper Wire i You can combine these functions to build complex if() statements.
Jumper Wire Pin 2 h6
For example:
5
Code to Note:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 5
Because we've connected the button to GND, it will read LOW when
if (button1State == LOW) it's being pressed. Here we're using the "equivalence" operator ("==")
to see if the button is being pressed.
15V
you press either button, and o if
you press both buttons. (See the IOREF
3. RESET
XT
SCL
13
SDA
IN GND
XR
12 13
your board or see the ~11
~10
~9
8
troubleshooting tips below. ISP LDIGITA
~6
7
)(PWM~ 4
ON
~3 ~5
TX
1 2
RX
0
Light Not Turning On e buttons we used here are similar to the buttons in
e pushbutton is square, and because of this it is easy to most video game controllers.
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.
CIRCUIT #6
Photo Resistor
6
5 volt So you’ve already played with a potentiometer, which
varies resistance based on the twisting of a knob. In
PIN 9 this circuit, you’ll be using a photo resistor, which
GND
(Ground)
Resistor Resistor
X 1 X 1 X 1 X 6 X 1
7
-
15V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A2
A5 ANALOG
XT
SCL
A4 A3
AREF
IN GND
12 13
ISP LDIGITA
~6 7
XR13
)(PWM~ 4
ON
~3 ~5 ~10~11
TX
1 2
RX
0 ~9
8
p.40
Circuit 6 : Photo Resistor
7-15V
IOREF
RESET
3.3V
5V
GND
POW
ER
VIN
GND
ANALOG
A1
A4
A2
A3
IN
A5
0
Component: Image Reference: Measuring resistive sensors:
Photo Resistor f5 f6
Many of the sensors you'll use (potentiometers, photoresistors, etc.) are
resistors in disguise. eir resistance changes in proportion to whatever they're
LED (5mm) + h20 h21 sensing (light level, temperature, sound, etc.).
-
- e RedBoard's analog input pins measure voltage, not resistance. But we
330 Resistor (sensor) j21 can easily use resistive sensors with the RedBoard by including them as
part of a "voltage divider".
5 volts
1
6
10K Resistor i1 i5 PINin A03
Jumper Wire j
Jumper Wire A0 j5
GND
(ground) (-)
Jumper Wire j + A voltage divider consists of two resistors. e "top" resistor is the sensor you'll be
Jumper Wire Pin 9 j20 using. e "bottom" one is a normal, xed resistor. When you connect the top resistor
to 5 volts, and the bottom resistor to ground. e 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!
Jumper Wire 5V +
Jumper Wire GND Although the sensor's resistance will vary, the resistive sensors (ex sensor light
sensor, softpot, and trimpot) in the SIK are around 10K ohms. We usually want
the xed resistor to be close to this value, so using a 10K resistor is a great choice
for the xed "bottom" resistor. Please note the xed resistor isn't necessarily the
bottom resistor. We do that with the photodiode only so that more
light = more voltage, but it could be ipped and we'd get the opposite response.
Circuit 2 Arduino Code:
6
Code to Note:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 6
lightLevel = map(lightLevel, 0, 1023, 0, 255); When we read an analog signal using analogRead(), it will be a
Parameters number from 0 to 1023. But when we want to drive a PWM pin
map(value, fromLow, fromHigh, toLow, toHigh) using analogWrite(), it wants a number from 0 to
value: the number to map 255. We can "squeeze" the larger range into the smaller
fromLow: the lower bound of the value's current range
range using the map() function.
fromHigh: the upper bound of the value's current range
toLow: the lower bound of the value's target range See http://arduino.cc/en/reference/map for more info.
toHigh: the upper bound of the value's target range
lightLevel = constrain(lightLevel, 0, 255); Because map() could still return numbers outside the
Parameters "to" range, we'll also use a function called constrain()
constrain(x, a, b) that will "clip" numbers into a range. If the number is
x:the number to constrain, all data types outside the range, it will make it the largest or smallest
a:the lower end of the range, all data types number. If it is within the range, it will stay the same.
b: the upper end of the range, all data types
See http://arduino.cc/en/reference/constrain for more info.
15V
A0
A1
ed and uploaded the code to your board A5
A2
ANALOG
SDASCL
AREF
A4 A3 XT
XR GND
or see the troubleshooting tips below. IN
13 13
12
~11
~10
~9
ISP LDIGITA 8
7
~6
)(PWM~4
ON
~3 ~5
TX 2
RX 1
0
LED Remains Dark A street lamp uses a light sensor to detect when to turn
is is a mistake we continue to make time and time the lights on at night.
again, if only they could make an LED that worked both
ways. Pull it up and give it a twist.
Temperature Sensor
5 volt
A temperature sensor is exactly what it sounds like – a
TMP36 sensor used to measure ambient temperature. is
(Precision Temperature Sensor) particular sensor has three pins – a positive, a ground,
and a signal. is is a linear temperature sensor. A change
1 VCC in temperature of one degree centigrade is equal to a
2 change of 10 millivolts at the sensor output. e TMP36
VOUT PIN A0
3 sensor has a nominal 750 mV at 25°C (about room
GND RedBoard temperature). In this circuit, you’ll learn how to
integrate the temperature sensor with your RedBoard,
and use the Arduino IDE’s serial monitor to display the
temperature.
GND
(Ground) When you’re building the circuit be careful not
to mix up the transistor and the temperature
sensor, they’re almost identical. Look for
“TMP” on the body of the temperature sensor.
X 1 X 5 GND
SIGNAL
+V
FRONT
+V
SIGNAL
GND
BACK
7
-
1
5
V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A5 A2
ANALOG
SCL
A4 A3 XT SDA
XR AREF
IN GND
13
12 13
~11
~10
~9
ISP LDIGITA 8
7
~6
)(PWM~ 4
ON ~5
~3
TX
1 2
RX
0
p.44
Circuit 7: Temperature Sensor
abcde f g h i
1 1
2 2
3 3
4 4
RESE
5 5
6 6
T
7 7
7-15V 8 8
9 9
10 10
SCL
11 11
SDA
12 12
AREF
13 13
GND
14 14
13
15 15
IOREF
12
16 16
RESET
~11
17 17
3.3V
~10
5V 18 18
~9
3
1
X
R
X
T
POWE
GND 19 19
8
DIGITA
VIN
R
GND 20 20
7 21 21
L
~6 22 22
ANALOG
~5
(PWM~
23 23
A1 4 24 24
)
A4
A2 ~3 25 25
A3 2 26 26
TX 1 27 27
RX 0 28 28
IN
A5
ISP
29 29
N
O
30 30
abcde f g h i
0
Component: Image Reference: Opening your serial monitor:
Temperature Sensor
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
Jumper Wire
0
7
Code to Note:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 7
Arduino Code:
15V
isn't working, make sure you have voltage: 0.73 deg C: 23.24 deg F: 73.84
assembled the circuit correctly voltage:
voltage :
0.73 0.73
deg C:
deg C: 3.
22.75 deg F: 72.96
23.24RESET deg F: 7 3.84
IOREF
5V
3V
23.24
deg F: 73.84
voltage: 0.73 degPOWERC:
23.24 deg F: 73.84
to your board or see the voltage:A2 0.73 A1
VIN
deg C:
GND
22.75 deg F: 72
RESET
0.73
deg C: 23.24 deg F: 73
A3 XT AREF
voltage:
A4 0.73 deg C: 22.75 deg F: 72.96 XR GND
IN 13 13
12
voltage: 0.73 deg C: 22.75 deg F: 72.96 ~11
~10
voltage: 0.73 deg C: 23.24 deg F: 73.84 ISP
8
~9
)(PWM~ 4 ~6
ON ~5
Nothing Seems to Happen Building climate control systems use a temperature sensor
is program has no outward indication it is working. To to monitor and maintain their settings.
see the results you must open the Arduino IDE's serial
monitor (instructions on previous page).
Gibberish is Displayed
is happens because the serial monitor is receiving data at
a di erent speed than expected. To x this, click the
pull-down box that reads "*** baud" and change it to
"9600 baud".
8
ircuit 2
A Single Servo
Servos are ideal for embedded electronics applications
No junction dot means no connection because they do one thing very well that motors cannot –
5 volt 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 speci c position. For example, a pulse of 1.5
SIG PIN 9
milliseconds will move the servo 90 degrees. In this circuit,
you’ll learn how to use PWM (pulse width modulation)
W
R
RedBoard to control and rotate a servo.
V+ B
GND
GND
(Ground)
Servo Wire
PARTS:
X 1 X 8
7 -
15V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A5
A2
ANALOG
SCL
A4 A3 XT
SDA
XR
AREF
IN 13 GND
12 13
~11
~10
~9
ISP LDIGITA 8
~6 7
)(PWM~ 4
ON ~5
~3
TX
1 2
RX
0
p.48
Circuit 8: A Single Servo
7-15V
IOREF
RESET
3.3V
5V
POWE
GND
VIN
R
GND
ANALOG
A1
A4
A2
A3
IN
A5
0
Component: Image Reference: Expand your horizons using Libraries:
Servo e5 e6 e7 e 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.
Jumper Wire e5
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
Jumper Wire e6
to more advanced devices (LCD displays, stepper motors, ethernet ports, etc.)
See http: //arduino.cc/en/reference/libraries for a list of the standard
Jumper Wire e7 libraries and information on using them.
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
Jumper Wire Pin 9 a7 that device to the RedBoard. Many of SparkFun's products come with Arduino
libraries, and you can nd 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!
Jumper Wire b5
To use a library in a sketch, select it from Sketch > Import Library.
Verify / Compile
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.
8
Code to Note:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 8
Arduino Code:
Servo servo1; e servo library adds new commands that let you control a servo.
To prepare the Arduino to control a servo, you must rst create a
servo1.attach(9); 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).
e servos in this kit don't spin all the way around, but they can be commanded
servo1.write(180); to move to a speci c position. We use the servo library's write() command to
move a servo to a speci ed number of degrees(0 to 180). Remember that the
servo requires time to move, so give it a short delay() if necessary.
Servo Not Twisting Robotic arms you might see in an assembly line or sci-
Even with colored wires it is still shockingly easy to plug a movie probably have servos in them.
servo in backward. is might be the case.
Flex Sensor
9
In this circuit, we will use a ex sensor to measure,
5 volt well, ex! A ex 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
Resistor (10K ohm) change it by exing (bending) the component. We
(Brown-Black-Orange) use a "voltage divider" again to detect this change in
SIG W PIN 9 PIN A0 resistance. e sensor bends in one direction and the
V+ R
GND
range from about 10K ohm to 35K ohm. In this
Flex Sensor
circuit we will use the amount of bend of the ex
sensor to control the position of a servo.
GND
(Ground)
ResistorResistor
X X 1 1 X 8 X1 X 8X1 X 11
IOREF
3. RESET
5V 3V
GND
POWER
VIN GND
A0
A1
A2
A5 ANALOG
A4 A3 XT
RX
IN GND
12 13
ISP
ON )(PWM~
~3
TX
1 2
RX
0
p. 5210
Circuit 9: Flex Sensor
7-15V
IOREF
RESET
3.3V
5V
GND
POW
ER
VIN
GND
ANALOG
A1
A4
A2
A3
IN
A5
0
Component: Image Reference: Debugging your sketches using the Serial Monitor:
Servo e1 e2 e3
It happens to everyone - you write a sketch which successfully compiles and
uploads, but you can't gure out why it's not doing what you want it to. Larger
Jumper Wire e1 computers have screens, keyboards, and mice that you can use to debug your
code, but tiny computers like the RedBoard have no such things.
Jumper Wire e2 e key to visibility into a microcontroller is output. is 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
Jumper Wire e3
data from the RedBoard to a window back on the host computer. is is great for
your sketch's nal output, but it's also incredibly useful for debugging.
Flex Sensor h19 h20
19
i
Circuit 2 Arduino Code:
9
Code to Note:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 9
VIN GND
GND
IN
XT
RX
13
circuit correctly and veri ed and 12
TX 2
RX 1
0
Servo Not Twisting Controller accessories for video game consoles like
Even with colored wires it is still shockingly easy to plug a Nintendo’s “Power Glove” use ex-sensing technology. It
servo in backwards. is might be the case. was the rst video game controller attempting to mimic
hand movement on a screen in real time.
Servo Not Moving as Expected
e sensor is only designed to work in one direction. Try
exing it the other way (where the striped side faces
out on a convex curve).
Soft Potentiometer 10
RedBoard
PIN 11
In this circuit, we are going to use yet another kind
of variable resistor – this time, a soft potentiometer
PIN 10
5 volt (or soft pot). is is a thin and exible strip that can
PIN 9 detect where pressure is being applied. By pressing
Resistors (330 ohm) down on various parts of the strip, you can vary the
RedBoard Soft Pot (Orange-Orange-Brown) resistance from 100 to 10K ohms. You can use this
PIN A0 ability to track movement on the soft pot, or simply
as a button. In this circuit, we’ll get the soft pot up
Resistor (10K ohm)
(Brown-Black-Orange) LED and running to control an RGB LED.
BLUE
GREE
RED
(Light-Emitting Diode)
N
GND
(Ground)
7-
15V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A2 SCL
A5 ANALOG
A4 A3
XR GND
IN
13 13
12
~11
~10
~9
ISP 8
~6 7
ON ~5
~3 4
RX 2
p.5610
Circuit 10: Soft Potentiometer
abcde f g h i
1 1
2 2
3 3
4 4
RESE
5 5
6 6
T
7 7
7-15V 8 8
9 9
10 10
SCL
11 11
SDA
12 12
AREF
13 13
GND
14 14
13
15 15
IOREF
12 16 16
RESET
~11 17 17
3.3V
~10 18
5V
~9
3
1
X
R
X
T
19
POWE
GND
8
DIGITA
VIN
R
GND 20
7 21 21
L
~6 22 22
ANALOG
~5
(PWM~
23 23
A1 4 24 24
)
A4
A2 ~3 25 25
A3 2 26 26
TX 1 27 27
RX 0 28 28
IN
A5
ISP
29 29
N
O
30 30
abcde f g h i
0
Component: Image Reference: Component: Image Reference:
a4 a5 a6 a7
RGB LED (5mm)
Jumper Wire 5V +
Soft Potentiometer 5V h18 h19 h20 Jumper Wire GND
330 Resistor e4 g4
80
2
330 Resistor e6 g6
330 Resistor e7 g7
Jumper Wire e
Jumper Wire Pin 10 h6
Jumper Wire j +
Jumper Wire A0 j19
Jumper Wire j
Circuit 2 Arduino Code:
10
Code to Note:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 10
15V
A0
A1
A5 A2
ANALOG
A4 A3 SDA
IN 13
13
~11 12
~10
ISP ~9
8
7
ON ~6
~5
4
TX
RX
0
LED Remains Dark or Shows Incorrect Color e knobs found on many objects, like a radio
With the four pins of the LED so close together, it’s for instance, are using similar concepts to the
sometimes easy to misplace one. Try double one you just completed for this circuit.
checking each pin is where it should be.
Bizarre Results
e most likely cause of this is if you’re pressing the
potentiometer in more than one position. is is normal
and can actually be used to create some neat results.
CIRCUIT #11
Buzzer
11
In this circuit, we'll again bridge the gap between the
Piezo Buzzer 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 o
hundreds of times a second, the buzzer will produce a
RedBoard tone. And if you string a bunch of tones together,
PIN 9 you've got music! is circuit and sketch will play a
classic tune. We'll never let you down!
GND
(Ground)
X 1 X 3
7
-
15V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A5 A2
ANALOG
SCL
A4 A3 XT
SDA
XR
AREF
IN 13 GND
12 13
~11
~10
~9
ISP LDIGITA 8
7
~6
)(PWM~ 4
ON
~3 ~5
TX
1 2
RX
0
p.60
Circuit 11: Piezo Elements
7-15V
IOREF
RESET
3.3V
5V
POWE
GND
VIN
R
GND
ANALOG
A1
A4
A2
A3
IN
A5
0
Component: Image Reference: Creating your own functions:
Piezo Element f9 f7 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
Jumper Wire i7
"add," which adds two numbers together and returns the result. Let's break it down.
return(x);
}
Your functions can take in values ("parameters"), and return a value, as this one does.
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.
If your function is returning a value from your function, put the type of the
return value in front of the function name. en 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).
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
infomation about functions.
Circuit 2 Arduino Code:
11
Code to Note:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 11
15V
VIN GND
make sure you have assembled A1
A0
RESET
A2
the circuit correctly and veri ed A5
A4
ANALOG
A3 XT AREF
SCL
XR GND
12
13
~11
board or see the ~9
~10
ISP LDIGITA 8
troubleshooting tips below. )(PWM~ 4 ~6
7
ON ~5
~3
RX
TX
1 2
0
12
ircuit 2
Spinning a Motor
5 volt
Remember before when you played around with a servo
motor? Now we are going to tackle spinning a motor.
Diode is requires the use of a transistor, which can switch a
(1N4148) DC Motor 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. e
transistor we are using for this circuit is rated at 40V max
RedBoard and 200 milliamps max – perfect for our toy motor!
Transistor When the motor is spinning and suddenly turned o , the
PIN 9 magnetic eld inside it collapses, generating a voltage
(P2N2222AG)
Resistor (330 ohm) spike. is can damage the transistor. To prevent this, we
(Orange-Orange-Brown) use a " yback diode", which diverts the voltage spike
GND around the transistor.
(Ground) When you’re building the circuit be careful not
to mix up the transistor and the temperature
sensor, they’re almost identical. Look for
“P2N2222A” on the body of the transistor.
EMITTER
BASE
COLLECTOR
FRONT
COLLECTOR
BASE
EMITTER
BACK
7
-
15V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A2
A5 ANALOG
SCL
A4 A3 XT
XR AREF
IN
13
GND
12 13
~11
~10
~9
ISP LDIGITA 8
~6 7
)(PWM~ 4
ON
~3 ~5
1
TX 2
RX
0
p.64
Circuit 12 : Spinning a Motor
abcde f g h i
1 1
2 2
3 3
4 4
RESET
5 5
6 6
7 7
8 8
7-15V
9 9
10 10
SCL 11 11
SDA 12 12
AREF 13 13
GND 14 14
13 15 15
IOREF
12 16 16
RESET
~11 17 17
3.3V
~10 18 18
5V
~9 19 19
3
1
X
R
X
T
GND
POW
8
DIGITA
ER
VIN
GND
20 20
7 21 21
L
~6 22 22
ANALOG
~5 23 23
(PWM
A1 4 24 24
~)
A4
A2 ~3 25 25
A3 2 26 26
TX 1 27 27
RX 0 28 28
IN
A5
ISP
29 29
N
O
30 30
abcde f g h i
0
Component: Image Reference: Putting it all together:
EMITTER
P2N2222A
BASE a1 a2 a3
Transistor P2N2222AG COLLECTOR E B C
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
Diode 1N4148 programming in general.
GNDb7 a3b11
Most of the sketches you write will be a loop with some or all of these steps:
DC Motor
e7 e11 1. Perform some sort of input
2. Make some calculations or decisions
330 Resistor 3. Perform some sort of output
e2 g2 4. Repeat! (Or not!)
Jumper Wire e1 We've already shown you how to use a bunch of erentdi 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.
Jumper Wire
Pin 9 j2
It's usually pretty easy to pull pieces of erentdi sketches together, just open them in
two windows, and copy and paste between them. is is one of the reasons we've been
Jumper Wire a7 + promoting "good programming habits". ings 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,
Jumper Wire e3 d11
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.)
Jumper Wire 5V + 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
Jumper Wire GND 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.
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!
12
Code to Note:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 12
Arduino Code:
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
speed = Serial.parseInt(); 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.
A0
A1
A2
RX
~3
check the troubleshooting section below. 1 2
TX
0
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.
5 volt
1
3
Resistor (330 ohm)
(Orange-Orange-Brown)
Diode
(1N4148)
SPDT Relay
RedBoard Transistor
PIN 2
(P2N2222AG)
In this circuit, we are going to use some of the lessons we
Resistor (330 ohm) learned in circuit 12 to control a relay. A relay is basically
(Orange-Orange-Brown)
an electrically controlled mechanical switch. Inside that
GND
(Ground) harmless looking plastic box is an electromagnet that, when
it gets a jolt of energy, causes a switch to trip. In this
circuit, you’ll learn how to control a relay like a pro –
giving your RedBoard even more powerful abilities!
LEDs
(Light-Emitting Diodes)
RelayIC
PAR
TransistorLED
TS:
7
-
15V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A5 A2
ANALOG XR
SCL
A4 A3 XT
AREF
IN 13 GND
12 13
~11
~10
~9
ISP LDIGITA 8
7
)(PWM~ 4 ~6
ON
~3 ~5
TX
1 2
RX
0
p.6810
Circuit 13: Relays
7-15V
IOREF
RESET
3.3V
5V
POWE
GND
VIN
R
GND
ANALOG
A1
A4
A2
A3
IN
A5
0
2 1
e14 e9
Relay
f15f13 f9
EMITTER
P2N2222A
BASE a2 a3 a4
Transistor P2N2222AG COLLECTOR E B C
29
LED (5mm) + c19 c20
LED (5mm) 4 9
19
0
Diode 1N4148
330 Resistor
330 Resistor
Jumper Wire a7 a9
Jumper Wire
Jumper Wire e b
Jumper Wire 5V +
Jumper Wire GND
Circuit 2 Arduino Code:
13
Code to Note:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 13
GN V
GN D P
LEDs alternate illuminating at 1- V
OWE
IN R
RESET
A
second intervals. If you don't, A
1
0
A2 SCL
A A SDA
XR
31
AREF
IN
assembled the circuit correctly, and 13
~1112
uploaded the correct sketch to the ~10
~9
ISP LDIGITA 8
board. Also, see the troubleshooting ~6
7
)(PWM~~5
tips below. ON
TX
~3 4
RX
1 2
0
Shift Register
5 volt Now we are going to step into the world of ICs (integrated
circuits). In this circuit, you’ll learn all about using a shift
Resistors (330 ohm)
PIN 2
14
11
SER VCC 16
1
(Orange-Orange-Brown) register (also called a serial-to-parallel converter). e shift
regis ter will give yo ur RedBoard an additio nal eight outpu ts ,
15
RedBoard
QA
PIN 3 SCK QB 3 using only three pins on your board. For this circuit, you’ll
10 SCL QC 2
PIN 4 RCK QD
QE
5 practice by using the shift register to control eight LEDs.
12 4
QF
13 6
OE QG
7
QH
8 9
GND QH*
LEDs
74HC595 (Light-Emitting Diodes)
GND
*Do not connect pin 9
(Ground) VCC
QB 1 16
QC 2 15 QA
QD 3 14 SER
QE 4 13 OE
QF 5 12 RCLK
QG 6 11 SRCLK
QH 7 10 SRCLR
QH’
GND 8 9
PARTS:
7
-
15V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A2
A5 ANALOG
SCL
A4 A3 XT
XR AREF
IN 13 GND
12 13
~11
~10
~9
ISP LDIGITA 8
~6 7
)(PWM~ 4
ON
~3 ~5
1
TX 2
RX
0
p.72
Circuit 14: Shift Register
7-15V
IOREF
RESET
3.3V
5V
POWE
GND
VIN
R
GND
ANALOG
A1
A4
A2
A3
IN
A5
0
Image Reference: Image Reference:
e e Component:
e e e e e 1 1
5 6 7 8 9 0 1 e12
IC f5 f6 f7 f8 f9 f10 f11 f12 Jumper Wire
Component:
You'll communicate with the shift register (and a lot of other parts) using an
interface called SPI, or Serial Peripheral Interface. is interface uses a
data
shiftOut(datapin, clockpin, MSBFIRST, data); line and a separate clock line that work together to move
data in or out of the RedBoard at high speed. e MSBFIRST parameter
speci es the order
in which to send the individual bits, in this case we're sending the Most
Signi cant Bit rst.
bitWrite(data, desiredPin, desiredState); 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 o . e RedBoard has several commands, such as
bitWrite(), that make this easy to do.
POWER
A0
ANALOG
SCL
A4 A3
they aren't, make sure you have XT
XR
SDA
AREF
IN 13 GND
assembled the circuit correctly and ~11
12 13
~10
veri ed and uploaded the code to ~9
ISP LDIGITA 8
your board. See the 7
~6
ON )(PWM~ ~5
troubleshooting tips below. ~3 4
RX
TX
1 2
0
e RedBoard's power LED goes out Similar to circuit #4, a scrolling marquee display delivers
is happened to us a couple of times, it happens when a message with multiple LEDs. Essentially the same task
the chip is inserted backward. If you x it quickly the shift register achieves here in Circuit #14.
nothing will break.
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: [email protected]
W
O
D
D
D
V
S
S
V
A
K
0
7
/
CIRCUIT #15
LCD 15
In this circuit, you’ll learn about how to use an LCD.
16x2 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
5 volt
program your board. In this circuit, you’ll learn the
basics of incorporating an LCD into your project.
dB
Re
oa
PIN 2
rd
PIN 3
PIN 4
PIN 5
PIN 11
PIN 12
GND
(Ground)
LEDPotentiometer330Wir
PARTS:
ICLCD e Wire
Resistor 19
X
X 1 X 1 X 168
7
-
15V
IOREF
3. RESET
5V 3V
GND
POWER
A0
A1
A2
A5 ANALOG XR
SCL
A4 A3 XT
AREF
IN 13 GND
12 13
~11
~10
~9
ISP LDIGITA 8
)(PWM~ 4 ~6 7
ON
~3 ~5
RX
TX
1 2
0
p.76
Circuit 15: LCD
7-15V
IOREF
RESET
3.3V
5V
POWE
GND
VIN
R
GND
ANALOG
A1
A4
A2
A3
IN
A5
0
9
in 19
f
P 2
f
LCD
Jumper Wire
Potentiometer
Jumper Wire
Jumper Wire
Jumper Wire j30
j29
Jumper Wire Pin 3 f18
j28
Jumper Wire
j27
Jumper Wire 4
j26
Jumper Wire
j25
Jumper Wire Pin 5 f20
Jumper Wire aa 3
j24 3 Jumper Wire Pin 11 f25
j23
16
j19
Jumper Wire Pin 12 f27
j18
j17
Jumper Wire +
j16
j15
Jumper Wire f30
b8
b7
b6
5V j10+
GND
GNDe6 a3+
GND e7 f28a3
GNDe8
GNDf15 a3
GND +
Pin 2 0jf17
Circuit 2 Arduino Code:
15
Code to Note:
Open Arduino IDE // File > Examples > SIK Guide > Circuit # 15
is bit of code tells your Arduino IDE to include the library for a
#include <LiquidCrystal.h> simple LCD display. Without it, none of the commands will
work, so make sure you include it!
VIN GND
A0
A1
A2
on your LCD. Remember A5
A4 A3
ANALOG
XT
SCL
SDA
XR
AREF
you can adjust the contrast IN 13 GND
12 13
~11
using the potentiometer if ~9
~10
~6
7
8
)(PWM~ 4
words clearly. If you have ON
~3
~5
e Screen is Blank or Completely Lit? LCDs are everywhere! From advanced LCDs like
Fiddle with the contrast by twisting the your television, to simple noti cation screens, this is
potentiometer. If it’s incorrectly adjusted, you a very common and useful display!
won’t be able to read the text.
Screen Is Flickering
Double check your connections to your
breadboard and Arduino.
Learning More
Visit us Online:
is 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
NOTES:
Begin your Journey The SparkFun Inventor’s Kit
teaches basic programming,
into Electronics for which you will need both a
This kit will guide you through computer and an internet connection.
experiments of varying difficulty
as you learn all about embedded
systems, physical computing,
You will also learn to
programming and more! This kit assemble 15 basic physical
is perfect for anyone who wants electronic circuits, but no
to explore the power of the soldering is required. No previous
RedBoard platform.
experience is necessary!
KIT INCLUDES
© SparkFun Electronics, inc. All rights reserved. The SparkFun Inventor’s 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 Inventor’s Kit for the SparkFun RedBoard is
licensed under the Creative Commons Attribution Share-Alike 3.0 Unported License