sik guide - mr. brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfcopy...

42
IOREF RESET RESET 7-15V SCL SDA AREF GND 13 12 ~11 ~10 ~9 8 7 ~6 ~5 4 ~3 2 1 0 TX RX 13 3.3V 5V GND GND VIN A0 A1 A2 A3 A4 A5 POWER ANALOG IN DIGITAL (PWM~) ON ISP TX RX LEARN. SHARE. HACK. SIK GUIDE Your guide to the SparkFun Inventor’s Kit for the SparkFun RedBoard OREF ET 15V 7 ~6 ~5 4 ~ TX RX DIGITAL (PWM O ARDUINO LANGUAGE DEVELOPMENT PLATFORM Version 3.2

Upload: others

Post on 11-Mar-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TXRX

13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

LEARN. SHARE. HACK.

SIK GUIDEYour guide to the SparkFun Inventor’s Kit for the SparkFun RedBoard

IORE

FRE

SET

RESET

7-15

V

SCL

SCA

AREF

GND

1312

~11

~10

~9 8

7~6

~5 4~3 2

10

TXRX

13

3.3V

5VGN

DGN

DVI

N

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)

ON

ISP

TXRX

ARDUINO LANGUAGE DEVELOPMENT PLATFORM

Version 3.2

Page 2: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

�e SparkFun Inventor's Guide is your map for navigating the waters of beginning embedded electronics. �is 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

Welcome to the SparkFun Inventor’s Guide

Table of Contents

Page 3: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

What is the RedBoard platform? 2

Download Arduino Software (IDE) 4

Install Drivers 5

Select your board: Arduino Uno 8

Download “SIK Guide Code” 9

The World Runs on Circuits 10

Inventory of Parts 12

14

16

18

25

29

33

37

41

45

49

53

Section 2: Getting Started with Circuits

Section 1: Getting Started

RedBoard

Breadboard

Circuit #1 - Your First Circuit: Blinking a LED

Circuit #3 - RGB LED

Circuit #4 - Multiple LEDs

Circuit #5 - Push Buttons

Circuit #6 - Photo Resistor

Circuit #7 - Temperature Sensor

Circuit #8 - A Single Servo

Circuit #9 - Flex Sensor

57Circuit #10 - Soft Potentiometer

61Circuit #11 - Piezo Buzzer

65Circuit #12 - Spinning a Motor

69Circuit #13 - Relay

73Circuit #14 - Shift Register

77Circuit #15 - LCD

81Circuit #16 - Simon Says

Circuit #2 - Potentiometer

Page 1

Page 4: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

We live in a unique time where we have access to resources that allow us to create our own solutions and inventions. �e DIY revolution is composed of hobbyists, tinkerers and inventors who would rather craft their own projects than let someone do it for them.

www.sparkfun.com

The DIY Revolution

What is the RedBoard platform?

FPOFPO

�e RedBoard in your hand (or on your desk) is your development platform. At its roots, the RedBoard is essentially a small portable computer. It is capable of taking inputs (such as the push of a button or a reading from a light sensor) and interpreting that information to control various outputs (like a blinking LED light or an electric motor).

�at's where the term "physical computing" is born - this board is capable of taking the world of electronics and relating it to the physical world in a real and tangible way. Trust us - this will all make more sense soon.

A Computer for the Physical World

RedBoard

// SparkFun RedBoard

�e SparkFun RedBoard is one of a multitude of development boards based on the ATmega328. It has 14 digital input/output pins (6 of which can be PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an ISP header, and a reset button. Don’t worry, you’ll learn about all these later.

Page 2

IOREF

RESET

RESET

7-15V

SCLSDA

AREFGND

1312

~11~10

~98

7~6~5

4~3

210

TXRX

13

3.3V

5V

GND

GND

VIN

A0

A1

A2

A3

A4

A5

POW

ERAN

ALOG IN

DIGITAL (PW

M~

)

ON

ISP

TX

RX

LE

AR

N. S

HA

RE

. HA

CK

.

Page 5: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

cb

a

d

e

f

g

h

c

b

a

f

e

d

h

g

Power-Lacing High Tops

Old Toy Email Notifer

Bug Zapper Counter

Re-Programmed Traffic Light

Auto-Plant Watering

Camera Time-lapse operation

Quadcopter

Auto-Coffee Maker

RedBoard

Page 3

Page 6: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

In order to get your RedBoard up and running, you'll need to download the newest version of the Arduino software �rst from www.arduino.cc (it's free!). �is software, known as the Arduino IDE, will allow you to program the board to do exactly what you want. It’s like a word processor for writing programs. With an internet-capable computer, open up your favorite browser and type in the following URL into the address bar:

Access the Internet

Download the Arduino IDE (Integrated Development Environment)

user

•••••••••

Windows

Mac OS X

Linux: 32 bit, 64 bit

N

W

S

E

NW

SW

SE

NE

arduino.cc/en/main/software

Choose the appropriate Operating System installation package for your computer.

Download Click on your appropriate computer operating system next to the “ + ” sign.

Windows

Mac OS X

source

Linux: 32 bit, 64 bit

1

Page 4

Page 7: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

// 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.

// Install Arduino DriversDepending on your computer’s operating system, you will need to follow speci�c instructions. Please go to www.sparkfun.com/FTDI for speci�c instructions on how to install the FTDI drivers onto your RedBoard.

23

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TXRX

13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

LEARN. SHARE. HACK.

Page 5

Page 8: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

1 2 3 5 6

7

8

9

4

Open the Arduino IDE software on your computer. Poke around and get to know the interface. We aren’t going to code right away, this is just an introduction. �is step is to set your IDE to identify your RedBoard.

// Open the Arduino IDE:

Page 6

Page 9: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

// The three most important commands for this guide are seen below:

GUI (Graphical User Interface)

Verify: Compiles and approves your code. It will catch errors in syntax (like missing semi-colons or parenthesis). // See Diagram Below1

Upload: Sends your code to the RedBoard. When you click it, you should see the lights on your board blink rapidly. // See Diagram Below2

New: This buttons opens up a new code window tab.3

Open: This button will let you open up an existing sketch. // See Diagram Below4

Save: This saves the currently active sketch.5

Serial Monitor: This will open a window that displays any serial information your RedBoard is transmitting. It is very useful for debugging.6

Code Area: This is the area where you compose the code for your sketch. 8

Message Area: This is where the IDE tells you if there were any errors in your code.9

Sketch Name: This shows the name of the sketch you are currently working on.7

Verify

Upload

Open

Page 7

Page 10: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

// Select your board: Arduino Uno

Select the serial device of the RedBoard from the Tools | Serial Port menu. �is is likely to be com3 or 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 disappears should be the RedBoard. Reconnect the board and select that serial port.

Select the serial device of the RedBoard from the Tools > Serial Port menu. On the Mac, this should be something with /dev/tty.usbmodem or /dev/tty.usbserial in it.

http://www.arduino.cc/playground/Learning/Linux

// S

elec

t you

r Ser

ial D

evic

e

4

Note:Your SparkFun RedBoard and the Arduino UNO are interchangeable but you won’t find the RedBoard listed in the Arduino Software. Select “Arduino UNO” instead.

Page 8

Page 11: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Type in the following URL to download the code:

Download Arduino Code (For use with the circuits in this guide)

sparkfun.com/sikcode

5

Unzip the �le “SIK Guide Code”. It should be located in your browser’s “Downloads” folder. Right click the zipped folder and choose “unzip”.

Copy the “SIK Guide Code” folder into Arduino’s folder named “examples”.

Copy the “SIK Guide Code” folder into Arduino’s folder named “examples”.

WHAT’S NEXT? Read on to learn more about getting started with circuits. �en you can start on your �rst circuit on page 17!

Unzip the �le “SIK Guide Code”. It should be loacted in your browser’s “Downloads” folder. Right click the zipped folder and choose “unzip”.

Find “Arduino” in your applications folder. Right click(ctrl + click) on “Arduino”. Select “Show Package Contents”.

http://www.arduino.cc/playground/Learning/Linux

// C

opy

“SIK

Gui

de C

ode”

into

“Ex

ampl

es”

libra

ry in

Ard

uino

fold

er

ProgramsStart arduino examples

Contents

Resources

Java

examples

Page 9

Page 12: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Everywhere you look, you'll �nd circuits. �e cell phone in your pocket, the computer that controls your car's emissions system, your video game console - all these things are chock full of circuits. In this guide, you'll experiment with some simple circuits and learn the gist of the world of embedded electronics.

The World Runs on Circuits:

Getting Started with Circuits

A circuit is basically an electrical loop with a starting point and an ending point - with any number of components in between. Circuits can include resistors, diodes, inductors, sensors of all sizes and shapes, motors, and any other handful of hundreds of thousands of components.

Circuits are usually divided into three categories - analog circuits, digital circuits, or mixed-signal circuits. In this guide, you will explore all three sets of circuits.

What is an Electrical Circuit?

// Simple and Complex Circuits

In this guide, you will be primarily exploring simple circuits - but that doesn't mean you can't do amazing things with simple tools! When you've �nished the SIK, your knowledge of circuits will enable you to explore amazing projects and unleash the power of your imagination.

a b c d e f g h i123456789101112131415161718192021222324252627282930

a b c d e f g h i

123456789101112131415161718192021222324252627282930

Page 10

Page 13: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Page 11

Page 14: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Inventory of Parts

* ACTUAL SIZE

(1N4148)Diode

x2

x1

Piezo Buzzer

Various ColorsJumper Wire

x30

Push Button

x4x1

DC Motor

x1

DC Motor

x1

Potentiometer

(Light Emitting Diode)

x1x5x5x5x5

LED (5mm) +-

330Ω Resistor

x25 * ACTUAL SIZE

10KΩ Resistor

x25 * ACTUAL SIZE

(TMP36)

x1

Temp. Sensor

FRONT

BACK

(P2N2222AG)

x2

Transistor

P2N2

222A

A18

FRONT

BACK

x1

Photo Resistor

Page 12

Page 15: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Standard Solderless Breadboard

a b c d e f g h i123456789101112131415161718192021222324252627282930

a b c d e f g h i

123456789101112131415161718192021222324252627282930

Standard Solderless (Color may vary) Breadboard

a b c d e f g h i123456789101112131415161718192021222324252627282930

a b c d e f g h i

123456789101112131415161718192021222324252627282930

SparkFun RedBoardFlex Sensor

x1

Soft Potentiometer

x1

Servo

x1

Relay

x1

x1

x1

LCD

x1

(IC)Integrated Circuit

x1

IOREF

RESET

RESET

7-15V

SCLSDA

AREFGND

1312

~11~10

~98

7~6~5

4~3

210

TXRX

13

3.3V

5V

GND

GND

VIN

A0

A1

A2

A3

A4

A5

POW

ERAN

ALOG IN

DIGITAL (PW

M~

)

ON

ISP

TX

RX

LE

AR

N. S

HA

RE

. HA

CK

.

Page 13

Page 16: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

IOREF

RESET

RESET

7-15V

SCLSDA

AREFGND

1312

~11~10

~98

7~6~5

4~3

210

TXRX

13

3.3V

5V

GND

GND

VIN

A0

A1

A2

A3

A4

A5

POW

ERAN

ALOG IN

DIGITAL (PW

M~

)

ON

ISP

TX

RX

LE

AR

N. S

HA

RE

. HA

CK

.

12

8

6

9

7

3 4 5

10

Page 14

Page 17: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

// Pins Diagram

SparkFun RedBoard

RFU - This pin is reserved for future use.11

Power In (Barrel Jack) - Can be used with either a 9V or 12V wall-wart or battery.1

Power In (USB Port) - Provides power and communicates with your board when plugged into your computer via USB.2

LED (RX: Receiving) - This shows when the FTDI chip is receiving data bits from the microcontroller. This happens when the microcontroller is sending data bits back to the computer.3

LED (TX: Transmitting) - This shows when the FTDI chip is transmitting data bits to the microcontroller. This happens when the microcontroller is receiving this data from the computer.4

LED (Pin 13: Troubleshooting) - This LED is incorporated into your sketch to show if your program is running properly.5

Pins (ARef, Ground, Digital, Rx, Tx) - These various pins can be used for inputs, outputs, power, and ground. // See Diagram Below 6

LED (Indicates RedBoard is ON) - This is a simple power indicator LED.7

Reset Button - This is a way to manually reset your RedBoard, which makes your code restart.8

Pins (Analog In, Power In, Ground, Power Out, Reset) - These various pins can be used for inputs, outputs, power, and ground. // See Diagram 10

ICSP Pins (Uploading Code without Bootloader) - This is for "In-Circuit Serial Programming," used if you want to bypass the bootloader.9

Power Out

Reset

IOREF

Power Out

Ground

Ground

Power In

Analog

Analog

Analog

Analog

Analog

Analog

Ground

ARef

SDA

SCL

Digital

Digital

Digital

Digital

Digital

Digital

Digital

Digital

Digital

Digital

Digital

Digital

TX - Out

RX - In

10

11

6

= PWM/Analog out compatible (i.e. )

The header pins are one of the most important parts for putting our example circuits together. Take a moment and locate the input/output ports of your RedBoard.

RFU

Page 15

Page 18: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

a b c d e f g h i123456789101112131415161718192021222324252627282930

a b c d e f g h i

123456789101112131415161718192021222324252627282930

This line divides the board in half, restricting electricity to one half or the other.

1

2

Page 16

Page 19: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

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.

Vertical Connection (+ Power and - Ground) - Power bus // See Diagram Below1

Horizontal Connection (a-e & f-j) // See Diagram Below)2

How’s it all connected?

View of the inside

f g h ia b c d e123456789101112131415161718192021222324252627282930

a b c d e f g h i

123456789101112131415161718192021222324252627282930

Breadboard

Above the breadboard

CONNECTED!

LED

Making a Connection:

Inside the breadboard

Page 17

Page 20: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

How It Works:

ASSEMBLE WRITE UPLOAD

Peel sticker off back of breadboard and stick into place.

Make sure the text on the RedBoard and breadboard are facing up so you can read them.

a b c d e f g h i123456789101112131415161718192021222324252627282930

a b c d e f g h i

123456789101112131415161718192021222324252627282930

Screw the RedBoard down and into place.

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TXRX

13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

LEARN. SHARE. HACK.

Connect the USB cable.

CIRCUIT #1 - Your First Circuit

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.

Page 18

IOREF

RESET

RESET

7-15V

SCLSDA

AREFGND

1312

~11~10

~98

7~6~5

4~3

210

TXRX

13

3.3V

5V

GND

GND

VIN

A0

A1

A2

A3

A4

A5

POW

ERAN

ALOG IN

DIGITAL (PW

M~

)

ON

ISP

TX

RX

LE

AR

N. S

HA

RE

. HA

CK

.

Page 21: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TXRX

13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

LEARN. SHARE. HACK.

PART

S: LED

1X

Wire

3X

330ΩResistor

1X This section lists the parts you will need to complete the circuit.

Circuit 2

LEDs (light-emitting diodes) are small, powerful lights that are used in many 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 toward more complex experiments.

Blinking an LED 1

Each circuit begins with a brief description of the what you are putting together and the expected result.

This is a schematic of your circuit.

This is an illustration of how the completed circuit should look. It is not necessary to use the black holder for the RedBoard and breadboard, but we recommend it for the first time inventor!

Components like resistors need to have their legs bent into 90° angles in order to correctly fit the breadboard sockets. You can also cut the legs shorter to make them easier to work with on the breadboard.

LED(Light-Emitting Diode)

Resistor (330 ohm)(Orange-Orange-Brown)

RedBoard

GND(Ground)

PIN 13

Page 19

Page 22: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

IOR

EF

RES

ET

RESET

7-15

V

SC

LS

DA

AR

EFG

ND 13 12

~11

~10 ~

9 8 7~

6~

5 4~

3 2 1 0

TXRX

13

3.3V

5V GN

D

GN

D

VIN

A0

A1

A2

A3

A4

A5

POWER ANALOG IN

DIGITAL (PWM~)

ON

ISP

TX RX

LEARN. SHARE. HACK.

Circ

uit 1

: Blin

king

an

LED

ab

cd

ef

gh

i1 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

ab

cd

ef

gh

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

LED:

Mak

e su

re th

e sh

ort l

eg,

mar

ked

with

flat

side

, goe

s int

o th

e ne

gativ

e po

sitio

n (-)

. 33

0Ω R

esis

tor:

The

colo

r ban

ding

sh

ould

read

ora

nge-

or-

ange

-bro

wn-

gold

. The

com

po-

nent

legs

can

go in

eith

er h

ole.

Jum

per W

ire: A

ll ju

mpe

r wire

s w

ork

the

sam

e. T

hey

are

used

to

conn

ect t

wo

poin

ts to

geth

er. T

his

guid

e w

ill sh

ow th

e w

ires w

ith d

iffer

ent

colo

red

insu

latio

ns fo

r cla

rity,

but

usi

ng

diffe

rent

com

bina

tions

of c

olor

s is

com

plet

ely

acce

ptab

le.

Fla

t E

dg

e

Sho

rt L

eg

Page 20

Page 23: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Com

pone

nt:

Imag

e Re

fere

nce:

LED

(5m

m)

+-

+-

c2c3

Jum

per W

irePi

n 13

e2

330Ω

Res

isto

ra3

GN

Da3

Jum

per W

ireG

ND

Jum

per W

ire5V5V

+“5

V” o

n th

e Re

dBoa

rd c

onne

cts t

o th

e ro

w m

arke

d “+

” on

the

brea

dboa

rd.

“Pin

13”

on

the

RedB

oard

con

nect

s to

sock

et “e

2” o

n th

e br

eadb

oard

.

“GN

D”

on th

e Re

dBoa

rd sh

ould

be

conn

ecte

d to

the

row

mar

ked

“-”

on th

e br

eadb

oard

.

Resi

stor

s are

pla

ced

in b

read

boar

d so

cket

s onl

y. T

he “

-” sy

mbo

l rep

rese

nts a

ny so

cket

in it

s ver

tical

co

lum

n on

the

Pow

er b

us.

Brea

dboa

rd: T

he w

hite

bac

kgro

und

repr

esen

ts a

conn

ectio

n to

a

brea

dboa

rd so

cket

spec

ified

by

a le

tter-n

umbe

r coo

rdin

ate

such

as

e2. T

hese

coor

dina

tes a

re m

erel

y su

gges

tions

that

alig

n w

ith th

e gr

aphi

c im

age.

RedB

oard

: The

red

back

grou

nd

repr

esen

ts a

conn

ectio

n to

one

of

the

RedB

oard

hea

der p

ins.

Com

pone

nts l

ike

LEDs

are

inse

rted

into

the

brea

dboa

rd so

cket

s c2(

long

leg)

c3(

shor

t leg

). St

eps

high

light

ed w

ith a

yel

low

war

ning

tria

ngle

repr

esen

t a p

olar

ized

com

pone

nt. P

ay sp

ecia

l att

entio

n to

th

e co

mpo

nent

’s m

arki

ngs i

ndic

ating

how

to p

lace

it o

n th

e br

eadb

oard

.

Page 21

Page 24: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Open Up the Arduino IDE software on your computer. Coding in the Arduino language will control your circuit. Open the code for Circuit 1 by accessing the “SIK Guide Code” you downloaded and placed into your “Examples” folder earlier.

Open Your First Sketch:

File Edit Sketch Tools Help

1.Basics2.Digital3.Analog4.Communication5.Control6.Sensors7.Displays8.StringsArduinoISPSIK Guide Code

EEPROMEthernetFirmataLiquid CrystalSDServoSoftwareSerialSPIStepperWire

Page SetupPrint

NewOpen...SketchbookExamplesCloseSaveSave As...UploadUpload Using Progammer

Circuit #1Circuit #2Circuit #3Circuit #4Circuit #5Circuit #6Circuit #7Circuit #8Circuit #9Circuit #10Circuit #11Circuit #12Circuit #13Circuit #14Circuit #15Circuit #16

Circuit #1

/* Blink

Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain.

*/

void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(13, OUTPUT); }

void loop() { digitalWrite(13, HIGH); // set the LED on delay(1000); // wait for a second digitalWrite(13, LOW); // set the LED off delay(1000); // wait for a second}

// Circuit #1

Page 22

Page 25: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Verify

Upload

// The result of a completed circuit with correct code after verified and uploaded.

�is compiles your code. �e IDE changes it from text into instructions the computer can understand.

�is sends the instructions via the USB cable to the computer chip on the RedBoard. �e RedBoard will then begin running your code automatically.

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TX RX 13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TXRX

13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

LEARN. SHARE. HACK.

Page 23

Page 26: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Circuit 2 Arduino Code:1

Troubleshooting:

LED Not Lighting Up?LEDs will only work in one direction. Try taking it out and twisting it 180 degrees (no need to worry, installing it backward does no permanent harm).

Program Not Uploading �is happens sometimes, the most likely cause is a confused serial port, you can change this in tools>serial port>

Still No Success?A broken circuit is no fun, send us an e-mail and we will get back to you as soon as we can: [email protected]

You should see your LED blink on and o�. If it isn't, make sure you have assembled the circuit correctly and veri�ed and uploaded the code to your board or see the troubleshooting tips below.

Before you can use one of the RedBoard's pins, you need to tell the RedBoard whether it is an INPUT or OUTPUT. We use a built-in "function" called pinMode() to do this.

When you're using a pin as an OUTPUT, you can command it to be HIGH (output 5 volts), or LOW (output 0 volts).

digitalWrite(13, HIGH);

pinMode(13, OUTPUT);

Code to Note:

Real World Application:

Almost all modern �at screen televisions and monitors have LED indicator lights to show they are on or o�.

Open Arduino IDE // File > Examples > SIK Guide > Circuit # 1

What you Should See:

This is where you will find the Arduino code for each circuit.

Remember to Verify and Upload your code.

See if your circuit is complete and working in this section.

Begin to understand how the Arduino code works. See below.

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TX RX 13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TXRX

13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

LEARN. SHARE. HACK.

This is a section dedicated to the most common mistakes made while assembling the circuit.

Here you will find examples of the circuit you just completed in the real world. Many of the theories in these circuits are used in things you use everyday!

Page 24

Page 27: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Circuit 2PA

RTS: Wire

19X

CIRCUIT #5

IC

1X

330ΩResistor

8X

LED

8X

Circuit 2

In this circuit you’ll work with a potentiometer. A potentiometer is also known as a variable resistor. When it’s connected with 5 volts across its two outer pins, the middle pin outputs a voltage between 0 and 5, depending on the position of the knob on the potentiometer. A potentiometer is a perfect demonstration of a variable voltage divider circuit. �e voltage is divided proportionate to the resistance between the middle pin and the ground pin. In this circuit, you’ll learn how to use a potentiometer to control the brightness of an LED.

Potentiometer

PART

S: Wire

6X

CIRCUIT #2 2

LED

1X

330ΩResistor

1X

Potentiometer

1X

p.10

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TXRX

13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

LEARN. SHARE. HACK.

LED(Light-Emitting Diode)

Resistor (330 ohm)(Orange-Orange-Brown)

RedBoard

GND(Ground)

RedBoard

Potentiometer

PIN 13

5 volt

PIN A0

Page 25

Page 28: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

IOR

EF

RES

ET

RESET

7-15

V

SC

LS

DA

AR

EFG

ND 13 12

~11

~10 ~

9 8 7~

6~

5 4~

3 2 1 0

TXRX

13

3.3V

5V GN

D

GN

D

VIN

A0

A1

A2

A3

A4

A5

POWER ANALOG IN

DIGITAL (PWM~)

ON

ISP

TX RX

LEARN. SHARE. HACK.

Circ

uit 2

: Pot

entio

met

er

ab

cd

ef

gh

i1 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

ab

cd

ef

gh

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 26

Page 29: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Com

pone

nt:

Imag

e Re

fere

nce:

Pote

ntio

met

er

e6Ju

mpe

r Wire

e8Ju

mpe

r Wire

Jum

per W

ireG

ND

Jum

per W

ire5V

Pin

13j2

0

Jum

per W

ireG

ND

Jum

per W

ire5V5V

+

+-

+-

h20

h21

LED

(5m

m)

330Ω

Res

isto

rj2

1+

Jum

per W

ireA0

e7

+

a6 a7 a8If

you

look

clos

ely at

you

r Red

Boar

d, y

ou'll

see s

ome p

ins l

abele

d "D

IGIT

AL",

and

som

e lab

eled

"AN

ALO

G".

Wha

t's th

e di�

eren

ce?

Man

y of

the d

evice

s you

'll in

terfa

ce to

, suc

h as

LED

s and

pus

hbut

tons

, hav

e on

ly tw

o po

ssibl

e sta

tes:

on an

d o�

, or a

s the

y're

kno

wn

to th

e Red

Boar

d,

"HIG

H" (

5 vo

lts) a

nd "L

OW

" (0

volts

). �

e dig

ital p

ins o

n an

Red

Boar

d ar

e gr

eat a

t get

ting

thes

e sig

nals

to an

d fro

m th

e out

side w

orld

, and

can

even

do

trick

s lik

e sim

ulat

ed d

imm

ing

(by

blin

king

on

and

o� re

ally

fast)

, and

seria

l co

mm

unica

tions

(tra

nsfe

rrin

g da

ta to

anot

her d

evice

by

enco

ding

it as

pat

tern

s of

HIG

H an

d LO

W).

But t

here

are a

lso a

lot o

f thi

ngs o

ut th

ere t

hat a

ren'

t jus

t "on

" or "

o�".

Tem

pera

ture

leve

ls, co

ntro

l kno

bs, e

tc. a

ll ha

ve a

cont

inuo

us ra

nge o

f valu

es

betw

een

HIG

H an

d LO

W. F

or th

ese s

ituat

ions

, the

Red

Boar

d o�

ers s

ix an

alog

inpu

ts th

at tr

ansla

te an

inpu

t vol

tage

into

a nu

mbe

r tha

t ran

ges f

rom

0 (0

vol

ts)

to 1

023

(5 v

olts)

. �e a

nalo

g pi

ns ar

e per

fect

for m

easu

ring

all th

ose "

real

wor

ld" v

alues

, and

allo

w y

ou to

inte

rface

the R

edBo

ard

to al

l kin

ds o

f thi

ngs.

Digi

tal v

ersu

s An

alog

:

DIGI

TAL

0 vo

lts 0

5 vo

lts

1023

toor

ANAL

OG

HIGH

on 5 vo

lts

LOW

off

0 vo

lts

Page 27

Page 30: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TX RX 13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TX RX 13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TXRX

13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

LEARN. SHARE. HACK.

Most traditional volume knobs employ a potentiometer.

Circuit 2 Arduino Code:2

Troubleshooting:

Sporadically Working �is is most likely due to a slightly dodgy connection with the potentiometer's pins. �is can usually be conquered by holding the potentiometer down.

Not WorkingMake sure you haven’t accidentally connected thewiper, the resistive element in the potentiometer, to digital pin 0 rather than analog pin 0. (the row of pins beneath the power pins).

LED Not Lighting Up?LEDs will only work in one direction. Try taking it out and twisting it 180 degrees (no need to worry, installing it backward does no permanent harm).

You should see the LED blink faster or slower in accordance with your potentiometer. If it isn't working, make sure you have assembled the circuit correctly and veri�ed and uploaded the code to your board or see the troubleshooting tips below.

A “variable” is a stored value you’ve given a name to. You must introduce, or "declare" variables before you use them; here we're declaring a variable called sensorValue, of type "int" (integer). Don't forget that variable names are case-sensitive!

int sensorValue;

Code to Note:

Real World Application:

Open Arduino IDE // File > Examples > SIK Guide > Circuit # 2

What you Should See:

�e Arduino is very very fast, capable of running thousands of lines of code each second. To slow it down so that we can see what it's doing, we'll often insert delays into the code. delay() counts in milliseconds; there are 1000 ms in one second.

delay(sensorValue);

We use the analogRead() function to read the value on an analog pin. analogRead() takes one parameter, the analog pin you want to use ("sensorPin"), and returns a number ("sensorValue") between 0 (0 volts) and 1023 (5 volts).

sensorValue = analogRead(sensorPin);

Page 28

Page 31: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Circuit 2PA

RTS:

p.10

IC

1X

330ΩResistor

8X

LED

8X

You know what’s even more fun than a blinking LED? Changing colors with one LED. RGB, or red-green-blue, LEDs have three di�erent color-emit-ting diodes that can be combined to create all sorts of colors. In this circuit, you’ll learn how to use an RGB LED to create unique color combinations. Depending on how bright each diode is, nearly any color is possible!

RGB LED

PART

S:CIRCUIT #3 3

Potentiometer

1X

TransistorP2N2222AG

1X

Wire

6X

330ΩResistor

3X

LED

1X

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TXRX

13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

LEARN. SHARE. HACK.

red

commongreen

blue

GND(Ground)

RED

GREEN

BLUE

RedBoard

PIN 11

PIN 10

PIN 9

Resistors (330 ohm)(Orange-Orange-Brown)

LED(Light-Emitting Diode)

Page 29

Page 32: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

IOR

EF

RES

ET

RESET

7-15

V

SC

LS

DA

AR

EFG

ND 13 12

~11

~10 ~

9 8 7~

6~

5 4~

3 2 1 0

TXRX

13

3.3V

5V GN

D

GN

D

VIN

A0

A1

A2

A3

A4

A5

POWER ANALOG IN

DIGITAL (PWM~)

ON

ISP

TX RX

LEARN. SHARE. HACK.

Circ

uit 3

: RGB

LED

ab

cd

ef

gh

i1 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

ab

cd

ef

gh

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

* The

long

est l

ead

is th

e co

mm

on(g

nd).

Page 30

Page 33: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Com

pone

nt:

Imag

e Re

fere

nce:

e7e11

5V33

0Ω R

esis

tor

g4e4 e7

e115V

330Ω

Res

isto

rg6

e6 e7e11

5V33

0Ω R

esis

tor

g7e7

RGB

LED

(5m

m)

Jum

per W

ireG

ND

Jum

per W

ire5V5V

+

Jum

per W

irePi

n 9

h4

Jum

per W

irePi

n 10

h6

Jum

per W

irePi

n 11

h7

e5Ju

mpe

r Wire

We'v

e se

en th

at th

e Ar

duin

o ca

n re

ad a

nalo

g vo

ltage

s (vo

ltage

s bet

wee

n 0

and

5 vo

lts) u

sing

the

anal

ogR

ead(

) fun

ctio

n. Is

ther

e a

way

for t

he R

edBo

ard

to

outp

ut a

nalo

g vo

ltage

s as w

ell?

�e

answ

er is

no.

.. an

d ye

s. �

e R

edBo

ard

does

not

hav

e a

true

ana

log

volta

ge

outp

ut. B

ut, b

ecau

se th

e R

edBo

ard

is so

fast,

it c

an fa

ke it

usin

g so

met

hing

ca

lled

PW

M ("

Pul

se-W

idth

Mod

ulat

ion"

). �

e pi

ns o

n th

e R

edBo

ard

with

“~

” ne

xt to

them

are

PW

M/A

nalo

g ou

t com

patib

le.

�e

Red

Boar

d is

so fa

st th

at it

can

blin

k a

pin

on a

nd o

� al

mos

t 100

0 tim

es

per s

econ

d. P

WM

goe

s one

step

furt

her b

y va

ryin

g th

e am

ount

of t

ime

that

th

e bl

inki

ng p

in sp

ends

HIG

H v

s. th

e tim

e it

spen

ds L

OW

. If i

t spe

nds m

ost

of it

s tim

e H

IGH

, a L

ED c

onne

cted

to th

at p

in w

ill a

ppea

r brig

ht. I

f it

spen

ds m

ost o

f its

time

LOW

, the

LED

will

look

dim

. Bec

ause

the

pin

is bl

inki

ng m

uch

faste

r tha

n yo

ur e

ye c

an d

etec

t, th

e R

edBo

ard

crea

tes t

he

illus

ion

of a

"tr

ue"

anal

og o

utpu

t.

The

shoc

king

trut

h be

hind

ana

logW

rite(

):

90%90

%

50%

50%

0.5V

2.5V

4.5V

LOW

(0 v

olts

)

HIG

H (5

vol

ts)

LOW

(0 v

olts

)

HIG

H (5

vol

ts)

LOW

(0 v

olts

)

HIG

H (5

vol

ts)

10%

10%

a4a5

a6a7

Page 31

Page 34: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Many electronics such as videogame consoles use RGB LEDs to have the versatility to show di�erent colors in the same area. Often times the di�ent colors represent di�erent states of working condition.

Circuit 2 Arduino Code:3

Troubleshooting:

LED Remains Dark or Shows Incorrect ColorWith the four pins of the LED so close together, it’s sometimes easy to misplace one. Double check each pin is where it should be.

Seeing Red�e red diode within the RGB LED may be a bit brighter than the other two. To make your colors more balanced, use a higher Ohm resistor. Or adjust in code.

analogWrite(RED_PIN, redIntensity); to

analogWrite(RED_PIN, redIntensity/3);

You should see your LED turn on, but this time in new, crazy colors! If it isn't, make sure you have assembled the circuit correctly and veri�ed and uploaded the code to your board or see the troubleshooting tips below.

Code to Note:

Real World Application:

Open Arduino IDE // File > Examples > SIK Guide > Circuit # 3

What you Should See:

A for() loop is used to step a number across a range, and repeatedly runs code within the brackets {}. Here the variable "x" starts a 0, ends at 767, and increases by one each time ("x++").

for (x = 0; x < 768; x++){}

�e RedBoard is very very fast, capable of running thousands of lines of code each second. To slow it down so that we can see what it's doing, we'll often insert delays into the code. delay() counts in milliseconds; there are 1000 ms in one second.

delay(sensorValue);

"If / else" statements are used to make choices in your programs. �e statement within the parenthesis () is evaluated; if it's true, the code within the �rst brackets {} will run. If it's not true, the code within the second brackets {} will run.

if (x <= 255){}else{}

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TX RX 13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TXRX

13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

LEARN. SHARE. HACK.

Page 32

Page 35: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

So you have gotten one LED to blink on and o� – fantastic! Now it's time to up the stakes a little bit – by connecting EIGHT LEDS AT ONCE. We'll also give our RedBoard a little test by creating various lighting sequences. �is circuit is a great setup to start practicing writing your own programs and getting a feel for the way RedBoard works.

Along with controlling the LEDs, you’ll learn about a couple programming tricks that keep your code neat and tidy:

for() loops - used when you want to run a piece of code several times

arrays[ ] - used to make managing variables easier by grouping them together

Multiple LEDs

PART

S: LED

8X

Wire

10X

330ΩResistor

8X

CIRCUIT #4 4

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TXRX

13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

LEARN. SHARE. HACK.

Resistors (330 ohm)(Orange-Orange-Brown)

LEDs(Light-Emitting Diodes)

RedBoard

PIN 2

PIN 3

PIN 4

PIN 5

GND (Ground)

Resistors (330 ohm)(Orange-Orange-Brown)

LEDs(Light-Emitting Diodes)

RedBoard

PIN 6

PIN 7

PIN 8

PIN 9

GND (Ground)

Page 33

Page 36: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

IOR

EF

RES

ET

RESET

7-15

V

SC

LS

DA

AR

EFG

ND 13 12

~11

~10 ~

9 8 7~

6~

5 4~

3 2 1 0

TXRX

13

3.3V

5V GN

D

GN

D

VIN

A0

A1

A2

A3

A4

A5

POWER ANALOG IN

DIGITAL (PWM~)

ON

ISP

TX RX

LEARN. SHARE. HACK.

Circ

uit 4

: Mul

tiple

LED

s

ab

cd

ef

gh

i1 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

ab

cd

ef

gh

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 34

Page 37: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Com

pone

nt:

Imag

e Re

fere

nce:

Com

pone

nt:

Imag

e Re

fere

nce:

330Ω

Res

isto

ra1

8G

ND

330Ω

Res

isto

r

330Ω

Res

isto

r

Jum

per W

ire

Jum

per W

ire

Jum

per W

ire

Jum

per W

ire

Jum

per W

ire

Jum

per W

ire

Jum

per W

ire

Jum

per W

ire

Jum

per W

ire5V

Jum

per W

ire

LED

(5m

m)

+-

+-

c2c3

e2Pi

n 2

330Ω

Res

isto

ra1

5

330Ω

Res

isto

ra1

2

330Ω

Res

isto

ra9

330Ω

Res

isto

r

330Ω

Res

isto

ra6a3

LED

(5m

m)

+-

+-

c23

c24

LED

(5m

m)

+-

+-

c20

c21

LED

(5m

m)

+-

+-

c17

c18

LED

(5m

m)

+-

+-

c14

c15

LED

(5m

m)

+-

+-

c11

c12

LED

(5m

m)

+-

+-

c8c9

LED

(5m

m)

+-

+-

c5c6

a18

a24

a21

Pin

3

5V

e5

GN

D

Pin

4e8

Pin

5e1

1

Pin

6e14

Pin

7e17

Pin

8e2

0

Pin

9e2

3 +

Page 35

Page 38: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Page 36

Circuit 2 Arduino Code:4

Troubleshooting:

Some LEDs Fail to Light It is easy to insert an LED backwards. Check the LEDs that aren't working and ensure they the right way around.

Operating out of sequenceWith eight wires it's easy to cross a couple. Double check that the �rst LED is plugged into pin 2 and each pin there after.

Starting AfreshIts 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.

�is is similar to circuit number one, but instead of one LED, you should see all the LEDs blink. If they aren't, make sure you have assembled the circuit correctly and veri�ed and uploaded the code to your board or see the troubleshooting tips below.

Code to Note:

Real World Application:

Scrolling marquee displays are generally used to spread short segments of important information. �ey are built out of many LEDs.

Open Arduino IDE // File > Examples > SIK Guide > Circuit # 4

What you Should See:

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TX RX 13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TXRX

13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

LEARN. SHARE. HACK.

When you have to manage a lot of variables, an "array" is a handy way to group them together. Here we're creating an array of integers, called ledPins, with eight elements.

int ledPins[] = {2,3,4,5,6,7,8,9};

Computers like to do the same things each time they run. But sometimes you want to do things randomly, such as simulating the roll of a dice. �e random() function is a great way to do this. See http://arduino.cc/en/reference/random for more information.

index = random(8);

You refer to the elements in an array by their position. �e �rst element is at position 0, the second is at position 1, etc. You refer to an element using "ledPins[x]" where x is the position. Here we're making digital pin 2 HIGH, since the array element at position 0 is "2".

digitalWrite(ledPins[0], HIGH);

Page 39: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Page 37

Circuit 2PA

RTS: Wire

19X

IC

1X

330ΩResistor

8X

LED

8X

Circuit 2

Up until now, we’ve focused solely on outputs. Now we’re going to go to the other end of spectrum and play around with inputs. In this circuit, we’ll be looking at one of the most common and simple inputs – a push button. �e way a push button works with RedBoard is that when the button is pushed, the voltage goes LOW. �e RedBoard reads this and reacts accordingly. In this circuit, you will also use a pull-up resistor, which keeps the voltage HIGH when you're not pressing the button.

Push Buttons

PART

S: Wire

7X

CIRCUIT #5 5

Push Button

2X

LED

1X

330ΩResistor

1X

10KΩResistor

2X

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TXRX

13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

LEARN. SHARE. HACK.

Resistors (330 ohm)(Orange-Orange-Brown)

GND(Ground)

Resistors (10K ohm)(Brown-Black-Orange)

LED(Light-Emitting Diode)

RedBoard

Buttons

PIN 13

PIN 2PIN 3

5 volt

Page 40: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

IOR

EF

RES

ET

RESET

7-15

V

SC

LS

DA

AR

EFG

ND 13 12

~11

~10 ~

9 8 7~

6~

5 4~

3 2 1 0

TXRX

13

3.3V

5V GN

D

GN

D

VIN

A0

A1

A2

A3

A4

A5

POWER ANALOG IN

DIGITAL (PWM~)

ON

ISP

TX RX

LEARN. SHARE. HACK.

Page 38

Circ

uit 5

: Pus

h Bu

ttons

ab

cd

ef

gh

i1 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

ab

cd

ef

gh

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 41: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Page 39

Com

pone

nt:

Imag

e Re

fere

nce:

LED

(5m

m)

+-

+-

h20

h21

Push

But

ton

d4g4

d6g6

Push

But

ton

d9g9

d11

g11

Jum

per W

irePi

n 2

h6

Jum

per W

irePi

n 3

h11

Jum

per W

irePi

n 13

j20

i4Ju

mpe

r Wire

i9Ju

mpe

r Wire

10KΩ

Res

isto

ra1

5i6

+

10KΩ

Res

isto

ri1

1+

330Ω

Res

isto

rj2

1+

One

of t

he th

ings

that

mak

es th

e Red

Boar

d so

use

ful i

s tha

t it c

an m

ake c

ompl

ex d

ecisi

ons

base

d on

the i

nput

it's

getti

ng. F

or ex

ampl

e, yo

u co

uld

mak

e a th

erm

osta

t tha

t tur

ns o

n a

heat

er if

it g

ets t

oo co

ld, a

fan

if it

gets

too

hot,

wat

ers y

our p

lants

if th

ey g

et to

o dr

y, et

c.

In o

rder

to m

ake s

uch

decis

ions

, the

Ard

uino

envi

ronm

ent p

rovi

des a

set o

f log

ic op

erat

ions

th

at le

t you

bui

ld co

mpl

ex "i

f" st

atem

ents.

�ey

inclu

de:

You

can

com

bine

thes

e fun

ctio

ns to

bui

ld co

mpl

ex if

() sta

tem

ents.

For e

xam

ple:

if ((

mod

e ==

hea

t) &

& ((

tem

pera

ture

< th

resh

old)

|| (o

verr

ide

== tr

ue))

){ di

gita

lWri

te(H

EAT

ER, H

IGH

);} ...

will

turn

on

a hea

ter i

f you

're in

hea

ting

mod

e AN

D th

e tem

pera

ture

is lo

w, O

R if

you

tu

rn o

n a m

anua

l ove

rrid

e. U

sing

thes

e log

ic op

erat

ors,

you

can

prog

ram

you

r Red

Boar

d to

m

ake i

ntell

igen

t dec

ision

s and

take

cont

rol o

f the

wor

ld ar

ound

it!

How

to u

se lo

gic

like

a Vu

lcan

:

==

EQUI

VALE

NCE

A ==

B is

true

if A

and

B a

re th

e SA

ME.

!=DI

FFER

ENCE

A !=

B is

true

if A

and

B a

re N

OT T

HE S

AME.

&&

AND

A &

& B

is tr

ue if

BOT

H A

and

B ar

e TR

UE.

||OR

A ||

B is

true

if A

or B

or B

OTH

are

TRUE

.

!NO

T!A

is T

RUE

if A

is F

ALSE

. !A

is F

ALSE

if A

is T

RUE.

Jum

per W

ireG

ND

Jum

per W

ire5V

+

Page 42: SIK GUIDE - Mr. Brownlhsmbrown.weebly.com/uploads/8/6/7/8/86783366/redboard_sik_3.2_part_i.pdfCopy the “SIK Guide Code” folder into Arduino’s folder named “examples”. Copy

Page 40

�e buttons we used here are similar to the buttons in most video game controllers.

Circuit 2 Arduino Code:5

Troubleshooting:

Light Not Turning On �e pushbutton is square, and because of this it is easy to put it in the wrong way. Give it a 90 degree twist and see if it starts working.

Underwhelmed No worries, these circuits are all super stripped down to make playing with the components easy, but once you throw them together the sky is the limit.

You should see the LED turn on if you press either button, and o� if you press both buttons. (See the code to �nd out why!) If it isn't working, make sure you have assembled the circuit correctly and veri�ed and uploaded the code to your board or see the troubleshooting tips below.

Code to Note:

Real World Application:

Open Arduino IDE // File > Examples > SIK Guide > Circuit # 5

What You Should See:

�e digital pins can be used as inputs as well as outputs. Before you do either, you need to tell the RedBoard which direction you're going.

pinMode(button2Pin, INPUT);

Because we've connected the button to GND, it will read LOW when it's being pressed. Here we're using the "equivalence" operator ("==") to see if the button is being pressed.

if (button1State == LOW)

To read a digital input, you use the digitalRead() function. It will return HIGH if there's 5V present at the pin, or LOW if there's 0V present at the pin.

button1State = digitalRead(button1Pin);

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TX RX 13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

IOREFRESET

RESET

7-15V

SCLSDAAREFGND1312~11~10~98

7~6~54~3

21

0

TXRX

13

3.3V5VGNDGNDVIN

A0A1

A2A3

A4A5

POWER

ANALOG IN

DIGITAL (PWM~)ON

ISP

TXRX

LEARN. SHARE. HACK.