Vous êtes sur la page 1sur 68

St

In ar
th tr o t w
El e C du ith
ec r
c A
tr ea tio rd
on tiv n u
ic e to ino
s Us
:
e
of

Made in Germany.

by

e
St

fa

He

rm

an

Dont have a
Fritzing Creator Kit yet?
Well, you can close this PDF then. Were really sorry
but thats just the way it goes sometimes ...
But wait, we didnt mean it that way. You can check out
the content first to see how you like it.
Have fun with your projects! You can always buy a
Creator Kit another time as a:
Birthday present
Reconciliation gift
Educational gift
Christmas present
A present for bragging rights
Mothers Day gift
Fathers Day gift
Housewarming gift
Gift YOU ask for
And dont forget: The Fritzing Creator Kit is also
available for Schools, Universities and Labs as a Teaching-Bundle.
We look forward to your next visit in our Shop!

To the Webshop >


PS: Please share this document and if you have any
questions, drop us a line: support@fritzing.org

Thank you for purchasing the Fritzing Creator Kit. This


kit provides everything you need to get started in the
world of creative electronics, and we promise you that
it will be a highly entertaining and exciting journey.
All the experience that we've gained from teaching
at the University of Applied Sciences in Potsdam and
from countless workshops has been incorporated into
this kit. Try things out first, understand later this
approach will start you off with a good overview and
make your first steps really easy.
We recommend you to work on the examples
in the order they appear in this book the
later ones build on the earlier ones. If you
have difficulties at any point, please go to
fritzing.org/forum/creatorkit/troubleshooting.
Fritzing's free software allows you to share your ideas
with others, document your projects and even create
and produce your own board layouts. You will find
more interesting projects by other users in the Fritzing
project gallery: www.fritzing.org/projects.
Now we wish you lots of fun building, programming
and inventing.
Best regards

Stefan Hermann
Fritzing.org

Contents
Foreword3
Inspiration7

5. Analog Input 78
Potentiometer80
Electronic Basics 4:

1. Preparation 20
Component Overview 22

Reference Resistor 84
Automatic Lighting System 86
Ping Pong 90

Prototyping Environment 26
Installing Arduino Uno 28
Creator Kit Software Package 29
Arduino Board 30

6. Servomotor, Sound 92
Servo94
Synthesizer98

2. Digital Output 32
Blink34
Programming A Short Introduction 38

Battery102

7. Arduino meets Processing 104

Electronic Basics 1:

Firmata106

Voltage, Current and Power 40

Processing RGB 109

Chaser Lights 42

Magic Board 110

Electronic Basics 2:

Twitter Saurus 112

Electrical Resistance 46
Matrix50

3. Digital Input 54

8. From Prototype to Product 114


Fritzing116
Printed Circuit Boards (PCB) 118

FlipFlop56

Circuit Board Layout 120

Fortuneteller60

Fritzing Fab 125


Assembly of Components 126

4. Analog Output 64

Troubleshooting 128

Fading66
Night Light 70

Goal Achieved 129

Electronic Basics 3: Amplification 72

Aknowledgements130

Controlling a Motor with an H-Bridge 74

Imprint131

Inspiration
Before you get started, I'd like
to show you a few inspiring
projects that were implemented
with Fritzing, Arduino and related
technologies.

Little Black Midi


The Little Black Midi is a dress that singers and instrumentalists wear during stage performances. It allows
singing, dancing, and playing musical instruments to
be combined during performance. Midi samples are
triggered through the contact of copper plates and rings,
and a potentiometer adds effects to the microphone
track.
Project by Naomi Knopf
Fachhochschule Potsdam, Interface Design
www.incom.org/projekt/2967
Photo: Lily Roggemann

10

11

dandylight
Dandylights are dandelion-like objects that can be placed
on tables, for example in a caf. Each flower lights up in a
special colour. The flower stalk is made of a spring. If you
flick your flower in the direction of another flower, the
latter's light will change to the colour of the flower you
just flicked.
With these networked objects, it is easy to come into
contact with people in a discreet and playful way in public
places.
Project by Tommaso Bertagnin, Loris Bottello,
Stella Morelli and Valeria Sanguin
Universit IUAV di Venezia
www.interaction-venice.net/
iuav11-12lab2/projects/dandylight/

12

13

lumiBots
LumiBots are small, autonomous robots that move on a
luminescent background surface. With the help of a UV
LED, they leave behind a slowly fading, luminous trail.
Both older tracks and newer tracks are visible. The robots
have light sensors with which they are able to follow
the trails of light, thus reinforcing them. The result is a
constantly changing, generative image on a background
surface. With this process, lumiBots are able to visually
illustrate emergent effects such as "ant algorithms".
Project by Mey Lean Kronemann
www.meyleankronemann.de/lumibots
Photo: Michael Baumgartner

14

15

midiBricks
MidiBricks is a toolkit that helps musicians develop their
own custom music controllers. It lets one put together
one's own instrument on the spur of the moment.
The modular design requires neither electronics nor
programming skills.
All boards were designed with the Fritzing software and
produced with Fritzing Fab (see page 125).
Project by Stefan Hermann
Fachhochschule Potsdam, Interface Design
www.midibricks.com

16

17

BeeHive
Clemens Gruber is a beekeeper who uses the Arduino
board to keep track of the bees flying in and out of his
beehives. This way he knows in real time what his bees
are up to.
Additional sensors provide data about the temperature
in the interior of the beehive. Since bees heat up significantly before swarming, the beekeeper can be notified via
SMS when a swarm is about to leave.
Project by Clemens Gruber
www.imkerei-gruber.de

18

19

To Hear the Grass Growing


Growth is a continuous process that our senses usually
cannot grasp, as it can only be perceived after a certain
amount of time has elapsed. When caring for a plant,
its growth can only be appreciated after several days or
weeks. "To Hear the Grass Growing" makes the growth
of plants accessible to us by means of a continuously
changing soundscape. The grass that grows in the
installation generates electrical impulses like those of
a heartbeat. The more the plant grows, the slower and
stronger are the generated impulses.

Martin Kim Luge www.martinluge.de


Clemens Winkler www.clemenswinkler.com
FELD - studio for digital crafts www.feld.is
Digital Class UdK Berlin www.digital.udk-berlin.de
Project page www.bit.ly/14FcKP9

The installation comprises three levels. The growing grass


is on the upper level, its system of roots is underneath,
and the technology used to measure the growth and
generate the sound is on the bottom level.
Regular care helps the roots grow into an increasingly
complex system. A microcontroller measures the conductivity of the root system, the growth and the density
of nutrients, and when connected to an audio amplifier
generates sounds at different frequencies. This way,
the steady growth of the grass gives rise to a constantly
changing and growing world of sound.

20

21

1. Preparation

In this chapter:
you will get a general idea of the
parts included in the kit.
you will assemble the base plate.
you will install the Arduino software.
you will be introduced to the Arduino board.

23

The Fritzing Creator Kit includes:

24
Setup

25

12
21

17

1x Arduino Microcontroller-Board

2x breadboards to connect components and wires

1x base plate

1x

USB cable to connect the Arduino to your computer

14

13

Input

10

ICSP2

1x tilt switch switches when it is shaken or upended

2x push-buttons close an electrical circuit

30
G H

A B C D E

A B C D E

25

20

15

10

J
G H

30

25

20

RX0

15

TX0

10

ICSP

A5

ON

A4

ANALOG IN

A3

10

DIGITAL (PWM= )

A1

2x potentiometers variable resistors

Output

11

TM

A0

A2

11

Arduino

VIN

POWER

GND

12

GND

TX
RX

5V
GND

15

AREF

13

3V3

the intensity of the light striking its surface

20

16

1x photoresistor (LDR) changes its resistance in proportion to

IOREF
RESET

L293D

RESET

22

18

19

1x LED Matrix Display

10

1x RGB LED with three LEDs in one housing (red, green, blue)

11

1x Piezo buzzer generates acoustic signals

12

22 x light emitting diodes (LEDs)

13

1x servomotor rotation angle can be controlled from 0 180

14

1x DC motor (4.5 9V)

3
Other

15

10 x resistors 220

16

10 x resistors 100k

17

1x MOS-FET (field-effect transistor) is used to switch


high currents with low control currents

24

Connections / mounting

18

14 x plug cables, male to male, long

19

14 x extension cables, male to female

20

28 x plug cables, male to male, short

21

1x 9V battery clip

22

1x L293D motor driver (H-bridge)

23

1x Allen key

24

3x screws

25

3x spacers

25

10
16

14

15

13

22

21

11
12

23
5
17
8
6
24

25

1
20
9

19

18

26

27

Prototyping Environment
The Fritzing Creator Kit contains the base plate on which
the Arduino is screwed and the breadboards are glued.
Remember that once the breadboards are glued, they
can't be detached!
The breadboards are equipped with foam adhesive and a
protective film on their underside.

Assembly
1. Remove the backing from the first breadboard and
place it onto the base plate as shown in the illustration. Make sure the tabs on the long edge are
pointing to the interior.
2. Remove the backing from the second breadboard
and slide it from above over the tabs of the first
breadboard.

3. Use the screws and spacers to fix the Arduino board


on the base plate. Tighten the screws by hand.

28

29

Arduino Uno Installation

Creator Kit Software Package

To use the Arduino-board, you must first download


the Arduino Software from www.arduino.cc and install
it. Then you can connect the computer to the Arduino
board with the supplied USB cable. You will still have to
install a driver, depending on your operating system :
www.arduino.cc/en/Guide/HomePage.

The Creator Kit also includes software examples.


Download them at www.fritzing.org/creatorkit-code, and
extract the zip file. It contains:

Installing the driver for Windows*


Connect the Arduino to the PC and wait for the
automatic driver installation process to begin.
After a few moments, the installation will fail. Now,
open the Control Panel > System & Security, and select
System > Device Manager.
Under sub-item Ports (COM/LPT) appears
Unknown Device or Arduino UNO (COMxx).
Right click on it and choose the Update Driver Software
option.
Select the Browse my Computer for Driver software option,
and navigate to the Arduino Software folder you
downloaded.
Select the Drivers subfolder. Windows will install the
driver from there.

Sketch is the
program code used
by Arduino and
Processing

not needed when


using the Arduino
Installer for Windows

Arduino sketches*
> Processing Processing sketches
> Fritzing Fritzing schematics
creator-kit-de

> Fritzing Creator Kit

Copy the Fritzing Creator Kit folder into the Arduino user
folder:

Windows
Arduino user folder: /Documents/Arduino

Mac
Arduino user folder: /Documents/Arduino

Linux
Depending on your distribution, you will
find the corresponding instructions under
arduino.cc/playground/Learning/Linux

Installing the driver for OSX


The Arduino is immediately ready for use. Simply copy
the Arduino Software into the Applications folder.

Now you will find the Fritzing Creator Kit program


examples under File/Sketchbook/Fritzing Creator Kit/ in the
Arduino software.

Installing the driver for Linux


You can find Linux drivers and manuals under
www.arduino.cc/playground/Learning/Linux.
If you can launch the Arduino Software now,
you're ready for the next step. Otherwise,
please visit our troubleshooting page
www.fritzing.org/forum/creatorkit/troubleshooting
30

The download package also contains program examples


for Processing. You will need them for the chapter
Arduino meets Processing. They are in the Processing folder
and can be directly opened later on in the Processing
Software.

31

USB

0
RX0

L
TX
RX

ON

TM

Arduino

ICSP

supply pins

RX/TX LEDs
These LEDs show
transmission (TX
= transmit) and
reception (RX =
receive) from the
Arduino board to the
computer.
*

A5

A4

A3

A2

A1

ANALOG IN
A0

VIN

GND

GND

5V

POWER
3V3

IOREF

RESET

microcontroller
external
power supply

32

10

11

12

13

DIGITAL (PWM= )

ICSP2

TX0

GND

AREF

Arduino Board
The Arduino UNO board is a small printed circuit board
with a microcontroller chip mounted on it. A microcontroller is a small computer that has input and output
channels and can be programmed. The Arduino board
has a USB port with which it can be connected to the
computer. A software program also called Arduino is
used for programming. Arduino programs are called
sketches. Once the board is programmed, it also works
without a computer, for example if it's connected to a
power supply (7 12V) or batteries. (see page 102 Battery).

digital pins

RX/TX LEDs*

analog
input pins

5V = positive pole
GND = negative pole
There are three GND pins that are connected to each
other in the interior of the board, so it makes no
difference which GND pin you use. GND is the abbreviation for ground.

33

2. Digital
Output

In this chapter:
you will blink an LED.
you will learn what voltage and
current really are.
you will learn what a resistor is.

di|gi|tal:
whatever can assume
two states, such as
on / off, true / false

out|put
in the Arduino world,
whatever can be
turned on or off by a
microcontroller, such as
LEDs, motors, magnets,
light bulbs or speakers

you will build a chaser light.


you will generate faces on a screen.

#1:

Blink

An LED lights up when there is a voltage. However, it


is important to connect it properly. Attach the long leg
(anode) to the circuit's positive pole and the short leg
(cathode) to GND.

Difficulty: easy

Circuit: Fritzing / Blink.fzz


Code: Sketchbook/Fritzing Creator Kit/Blink

Fritzing Diagram*

All files are included


in the download
package (see page
29). You can also
open the schematics
with the Fritzing
Software.

Pin 13 on the Arduino board already has a series resistor


and a small LED connected to it. However, you can also
temporarily connect an LED for testing purposes, as
shown in the Fritzing diagram. Attach the long leg to pin
13 and the short leg to the GND pin next to it.

Fritzing Diagram

The circuit design


is realized with the
Fritzing Software (see
page 116).

Open the blink example in the Arduino software under


File > Sketchbook > Fritzing Creator Kit > Blink.
serial port

Schematic

The serial port is


used to exchange
data between
computers and
peripheral devices.

RX/TX LEDs

These LEDs show


transmission (TX
= transmit) and
reception (RX =
receive) of data
between the Arduino
and the PC.

36

An LED connected to +5V and GND lights continuously. You can control the LED by using a digital output
pin on the Arduino board which can be programmed
to HIGH (+5V) or LOW (GND). Since an LED may be
destroyed at 5V, a series resistor must be integrated in
the circuit. At 5V the resistance should be 220 ohms ()
(see p. 47 Electrical resistance).

To transfer the program to the Arduino board, select the


corresponding board under Tools > Board > Arduino UNO and
the corresponding port* under Tools > Port. On a computer
running Windows, it is usually the last entry (eg COM3), on
the Mac it can be either the first (to OSX 10.7) or the last
(from OSX 10.8) entry (eg dev/tty/usbmodemfa141).
Once you've chosen the correct settings, you can transfer
the sketch via File > Upload to the Arduino board. The RX/
TX LEDs* on the Arduino will briefly light up first, then the
LED on pin13 will start blinking.
See what happens if you turn the LED around.

37

If you have never programmed before, jump to the next


page Programming: A Short Introduction.
Code

int led = 13;

The integer variable (int) called led is created and


assigned a value of 13.

void setup() {
pinMode(led, OUTPUT);
}

setup method
The command pinMode(led, OUTPUT) declares the
digital channel 13 on the Arduino as an output.

void loop() {
digitalWrite(led, HIGH);
delay(1000);

loop method

digitalWrite(led, LOW);

This command sets the led pin to +5V (HIGH).


This command stops the program for 1000 milliseconds.
This command sets the led pin to GND (LOW);
This command stops the program for 1000 milliseconds.

delay(1000);
}

Exercise
1. Try to make the light blink at a
different rhythm.

The output graph


shows the voltage at
pin 13 and thus the
voltage across the
LED.

Output graph
Pin 13
5V
0V

Solved

Solutions:
Sketchbook/Fritzing Creator Kit/ Exercise1_1

0s

38

2. Try to blink an SOS in the Morse


code: short, short, short, long,
long, long, short, short, short
pause.

Solved

1s

2s

3s

4s

5s

Sketchbook/Fritzing Creator Kit/ Exercise1_2a


Sketchbook/Fritzing Creator Kit/ Exercise1_2b

39

Programming

A Short Introduction
Programming is actually nothing more than having
instructions (commands) executed in a given order or in
parallel.
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);

These commands are fixed words to which additional


information (arguments) can be passed.
digitalWrite(13, HIGH);

The parentheses () indicate that, in both methods,


arguments do not need to be passed. The keyword void
means that this type of method does not return a result
(which means there are also method types where this is
not the case). The braces { } contain the actual commands
used in the methods.
The setup() method is executed only once while
launching Arduino and is used to configure the Arduino.
The loop() method is continuously repeated and makes
up the actual core of the program.
Variables are another important structure in
programming. These are small storage units that can
be assigned values. Basically, it's what you've learned in
maths: X = 10. X is the variable and its value equals 10.
Variables must be initialised (declared). For this, the
variable type and variable name are specified. There is
also the option to enter a value directly.
int led = 13;

For example, the above command switches +5V to pin 13


on the Arduino board. Therefore digitalWrite is the
command, while 13 and HIGH are the arguments.

The integer variable of the type int with the name led is
created and assigned a value of 13.

Arduino groups commands into two methods that are


automatically called up by the Arduino software.

Wherever the variable name led is used, it will be


replaced by the value 13.

void setup(){
}

digitalWrite(led, HIGH);

Other variable types are, for example, fractional numbers


(float), letters (char) or character strings (String).

void loop(){
}

40

For more information, go to: www.codeacademy.com.

41

Electronic Basics 1:

Voltage and current in a circuit are measured with a


multimeter (not included in the Kit). Make sure you
connect and adjust the device correctly.

Voltage, Current and


Power
Measuring voltage

The Arduino board has an operating voltage of 5V


(volts). When compared with the 230V (dangerous!) from
the mains supply, the 5V needed by the Arduino are
absolutely harmless.

Voltage is measured
at points that have a
voltage.

in

in V

I in A

Voltage (U) can be described as the pressure in a line.


The more pressure, the more power. This power is what
we call electric power (P). It also depends on the flow of
current. Current (I) is the amount of electrons flowing
through a line. The "thicker" the line (conductivity), the
more current can flow through it. A typical LED has a
current consumption of 20mA (milliamps).
Current always flows from the positive pole to the
negative pole. Arduino calls the positive pole 5V or +5V,
and the negative pole is called ground (GND).

10A

The field of voltage, current, and power is of course far


more complex. If you want to know more about the
topic, I recommend you to go to the Wikipedia portal on
electronics: en.wikipedia.org/wiki/Portal:Electronics

Measuring current

The current is
measured by interrupting the circuit
and bridging it with
the meter.

in

in V

I in A
10A

Don't worry if you don't understand this yet. Just follow


the instructions and you'll learn just by doing.

COM

COM

Measuring resistance

The resistance of a
component can be
measured directly,
as shown in the
illustration.

in

in V

I in A
10A

42

COM

43

#2 :

Chaser Lights

Difficulty: medium

Circuit: Fritzing / Chaserlights.fzz


Code: Sketchbook/Fritzing Creator Kit/Chaserlights

We will now build an LED chaser circuit. Connect eight


LEDs each to a resistor and a digital output . If possible,
don't use pins 0 and 1 (RX and TX). They are needed to
transfer data to the computer.

Breadboard
Fritzing diagram

A breadboard is a board with holes into which electrical


components can be plugged. It is used for building
and testing circuits. Metal channels embedded in the
breadboard provide the electrical connections (horizontal
orange lines). The topmost and bottommost rows are
used for power distribution. This is where you connect
and distribute the GND and +5V from the Arduino board.
The holes on the inside of the breadboard are connected
in columns pointing to the board centre (see picture).

Schematic

44

45

Array

Code

An array is a list of several variables of the same variable


type.

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

In the program, an array of the int type is created, and


eight entries are assigned to it.

void setup() {
for (int i=0; i<pinsTotal; i=i+1){

The storage locations of the array can be accessed by:


pins[0] is 2, pins[1] is 3, etc. The first position in the
array is 0. That is, you access the array from 0 to 7 rather
than from 1 to 8.

pinMode(pins[i], OUTPUT);
}
}
void loop() {

for loop

for (int i=0; i<pinsTotal; i=i+1){


digitalWrite(pins[i], HIGH);
delay(100);
digitalWrite(pins[i], LOW);
}
for (int i=pinsTotal-1; i>0; i=i1){
digitalWrite(pins[i], HIGH);
delay(100);
digitalWrite(pins[i], LOW);
}

*instead of using
i=i+1 you can write
i++

The for loop is a repetition with a termination condition.


In the parentheses, the starting value (int i=0), the
conditional statement (i<pinsTotal) and action
(i=i+1)* are defined as parameters. Thus, the variable
i is incremented by 1 each time the loop is executed.
As soon as the value of i is no longer inferior to
pinsTotal, the repetition of the loop is terminated.
With the for loop, all eight pins can be declared as
OUTPUT with just three lines of code.

Exercise
Solved

1. Try to make the chaser lights run


from both sides inwards.
Solution:
Sketchbook/Fritzing Creator Kit/ Exercise2_1

46

47

Electronic Basics 2:

Abbreviation:

Electrical Resistance

Normal 5mm LEDs


(except low current
LEDs) almost always
work with a 220ohm
resistor.

As we have already seen in Electronic Basics 1, the flow


of current depends on conductivity. If conductivity is
reduced at any point by means of a resistor, current
flow will be limited in the entire line. The power drop is
converted into heat in the resistor.
Now if you connect an LED, for example, and a resistor
in a row, both components will share the voltage. At the
same time the resistance will limit current flow.
This type of connection is called a series connection and
is also referred to as a voltage divider. The current in this
circuit is the same at all points. We took advantage of
this effect in the previous example when we connected
a series resistor to protect the LED against excessive
voltage and high current.

A series resistor must fulfil two tasks: on the one hand,


it must compensate the voltage difference between the
voltage needed to operate the Arduino (5V) and the
operating voltage of the LED (2.1V); on the other hand,
it must limit the current flowing through the line to
the amount the LED can tolerate (0.02A). You can find
component-specific information on data sheets on the
Internet.
Formula

Rv = Uv / I
Series resistor = Voltage across resistor / Current

The voltage across a series resistor results from:


Formula

Uv = Total Voltage Operating Voltage of LED


Uv = Utot Uled
Uv = 5 V 2.1 V = 2.9 V

When applied to the upper formula we get


Formula

Rv = Uv / I
Rv = 2.9 V / 0.02 A = 145

Series resistor

48

Therefore, under ideal conditions, in this example the


resistance should be 145 (ohms). As resistors are sold
at fixed values (E-series), you can simply use one with a
higher value. For LEDs at 5volts it is common to use a
resistor of 220ohms.
49

Carbon film resistors

Metal film resistors

are orange and have a four band colour code.


10 103 = 10 000 ohm = 10 kOhm

are blue and have a five band colour code.


100 102 = 10 000 ohm = 10 kOhm

1 0 103

1%

1%

2%

2%

5%

5%

10%

10%

Tolerance

Tolerance

Percentage by which
resistance value may
vary.

6
8

0.1

Percentage by which
resistance value may
vary.

0.01

The Fritzing Creator Kit uses film resistors. They are


made of an insulator coated with a resistive film
connecting the two outer leads.
Resistors are distinguished by the resistive material
used in their coating, such as carbon film or metal film.
Metal film resistors are known for their high precision.

50

1 0 0 102

Exercise
1. What happens when you connect
the 100k resistor to the LED?

Solved!

2. What happens if you connect two


220 resistors one after the other
to the LED?

Solved!

51

#3:

Matrix

A matrix display consists of a number of LEDs arranged


on a grid.

Difficulty: hard

Circuit: Fritzing / Matrix.fzz


Code: Sketchbook/Fritzing Creator Kit/Matrix

LEDs are forward- biased and reverse-biased. If you let


the current flow in the reverse direction (cathode to
anode) through the LED, the LED will not light up. The LED
matrix takes advantage of this principle.

Fritzing diagram

The schematic view illustrates the internal structure. The


numbers on the matrix symbol identify the pins. They are
counted counterclockwise from the bottom left.
This is how the program works: If you switch the first
column to HIGH (+5V) and the first row to LOW (GND),
the LED where the column and the row meet will light up.
To turn all the LEDs on and off individually, the rows must
be run individually. Thus, the first row is set to HIGH,
while the columns are switched on and off according to
the display. Next, the first row is switched to LOW and the
second row to HIGH, etc.

Schematic
Make sure you insert the matrix in the right
direction. The notches on the edge of the
matrix must be arranged as shown in the
picture, the text is on the lower side.

Text on matrix on
this side

+
To bridge longer
distances you can
simply connect two
wires.

52

53

The arrays rowPins[] and columnPins[] store


information on how the matrix display is connected. For
a single LED to light up, the columnPin must be set to
HIGH and the rowPin set to LOW.

Code

int rowPins[8] = {9,3,2,12,15,11,7,6};


int columnPins[8] = {13,8,17,10,5,16,4,14};
int image[8][8]={
{0,1,0,0,0,0,1,0},

The array image[][] controls the matrix. 0 means off, 1


means on. To understand how this works, simply change
the entries in the array.

{1,1,1,0,0,1,1,1},
{0,1,0,0,0,0,1,0},
{0,0,0,1,1,0,0,0},
{0,0,0,1,1,0,0,0},

Here all the pins used are switched to output.

{1,0,0,0,0,0,0,1},
{0,1,1,1,1,1,1,0},

The two nested for loops produce two changing


coordinates (x and y).

{0,0,1,1,1,1,0,0}
};
void setup(){

When the image array at point x,y equals 1, the LED lights
up.

for (int i=0; i<8; i++){


pinMode(rowPins[i],OUTPUT);
pinMode(columnPins[i],OUTPUT);
}

On page 90 you will learn how to build


a ping pong game with the matrix.

}
void loop () {
for (int y=0; y<8; y++){
for (int x=0; x<8; x++){
if (image[x][y]==1){
digitalWrite(columnPins[x],HIGH);
} else {
digitalWrite(columnPins[x],LOW);
}
}

Please note the


double equal sign
(==).

Exercise
1. Change the entries in the array
image[8][8] to change the
display on the screen!

Solved

2. Develop an animation with two


images.

Solved

digitalWrite(rowPins[y],LOW);
delayMicroseconds(10);
digitalWrite(rowPins[y],HIGH);
}
}

Solutions:
Sketchbook/Fritzing Creator Kit/ Exercise3_1
Sketchbook/Fritzing Creator Kit/ Exercise3_2

54

55

3.

Digital Input

In this chapter:
you will build a circuit with a push-button.
you'll get to know the if statement.
you will have your fortune told.

di | gi | tal:
whatever can assume
two states, such as
on / off, true / false

in | put:
all events that can be
detected by the Arduino
board, such as pressing
a button, closing a
magnetic switch or
crossing a light gate.

#4:

Flip Flop

Difficulty: medium

Circuit: Fritzing / FlipFlop.fzz


Code: Sketchbook/Fritzing Creator Kit/FlipFlop
Fritzing diagram

Button

A push-button (as
opposed to a switch)
closes an electrical
circuit as long as you
press it. When you
stop pressing it, the
circuit opens again.

To add some kind of interaction, we use a digital input.


A digital input is an input that can assume two states. A
switch for example is either switched on or off, a pushbutton* either pressed or not pressed.
Digital inputs, such as a push-button, are connected to
the GND and to a digital pin on the Arduino board. At
the same time, a resistor (pull-up resistor) is connected
between the Arduino's digital pin and the +5V. It deflects
electrical interference when the button is not pressed.
When the button is pressed, the Arduino pin is connected
to GND (LOW), when it is open, there is a connection
through the resistor to the +5 V (HIGH).
The circuit is made up of two LEDs with series resistors
and a push-button with a pull-up resistor.

Schematic

58

59

The pin connected to the button is declared as (INPUT).

Code

int buttonPin=2;
int greenLED=9;

if statement

int redLED=10;

The if statement checks whether the condition in the


parentheses is true, and performs the commands in the
braces accordingly. The double equal sign must be used
for checking (==).

void setup(){
pinMode(buttonPin, INPUT);
pinMode(greenLED, OUTPUT);
pinMode(redLED, OUTPUT);
}
void loop(){
if (digitalRead(buttonPin)==LOW){
digitalWrite(greenLED, HIGH);

The command digitalRead(buttonPin) returns LOW


when the push-button is pressed. When the button is not
pressed, it is HIGH.
If the condition is false, the else statement can be used
to perform alternative functions. It will only be executed
when the condition in the if statement is false.

digitalWrite(redLED, LOW);
} else {
digitalWrite(greenLED, LOW);
digitalWrite(redLED, HIGH);
}
}

Exercise
1. Write a program in which you
can switch the LEDs on and off
without having to keep the button
pressed.

Solved

Solution:
Sketchbook/Fritzing Creator Kit/ Exercise4_1

60

61

#5:

Fortuneteller

Difficulty: medium

Circuit: Fritzing / Fortuneteller.fzz


Code: Sketchbook/Fritzing Creator Kit/Fortuneteller
Fritzing diagram

Now let's build our own private fortuneteller who will


predict our future. The circuit is made up of five LEDs and
a tilt switch. Take the paper model "Fortuneteller" and
place it over the LEDs.
How it's used: Ask a question and give the circuit a good
shake. Your answer will appear as if by magic. But don't
take the answers too seriously we can't assume any
responsibility! ;)

Schematic

Paper cut -out model


62

63

Code

int pins[] = {8,9,10,11,12};


int tiltPin = 3;
void setup() {
for (int i=0; i<5; i=i+1){
pinMode(pins[i],OUTPUT);
}
pinMode(tiltPin,INPUT);
randomSeed(analogRead(0));
}

randomSeed
This command initializes the random
function. Go here for more information:
http://arduino.cc/en/Reference/RandomSeed

random
void loop() {
if (digitalRead(tiltPin)==HIGH){
for (int i=0; i<5; i=i+1){

The random () function returns a random number, in our


example from 0 5 (the 5 is excluded though). The corresponding pin in the array will be switched on.

digitalWrite(pins[i],LOW);
}
int myRandom=random(0,5);
digitalWrite(pins[myRandom],HIGH);
delay(20);
}
}

64

65

4. Analog
Output

In this chapter:
you will dim an LED through a PWM channel.
you will build a night light.
you will get to know the transistor.

ana | log :
whatever can assume
a variety of different
states, such as pressure,
brightness, temperature
or angle of rotation

out|put:
in the Arduino world,
whatever can be
turned on or off by a
microcontroller, such as
LEDs, motors, magnets,
light bulbs or speakers

#6:

Fading

We already know how to make an LED go on and off and


how to read a button. Both are digital processes, that
is, they only know two states. Now we're ready to learn
about analog output. For example, it is used to influence
the brightness of LEDs or the rotation speed of motors.

Difficulty: easy

Circuit: Fritzing / Fading.fzz


Code: Sketchbook/Fritzing Creator Kit/Fading
Fritzing diagram

An Arduino board cannot realise a real analog output, so


it uses a trick to do this. It simply switches a channel on
and off very quickly. This process is called PWM (Pulse
Width Modulation). The ratio between on and off is what
controls for example the brightness of an LED (or how
bright the LED appears to us).

The Arduino has an


8-bit PWM output.
Each bit can be 0 or
1, this results is 28
= 256 states, or 0 to
255.

The Arduino UNO board has six PWM channels,


marked on the board with a wavy line. The pulse width
modulation can output values from 0 (all the way off) to
255 (all the way on).*
The circuit example consists of an LED that is connected
to a PWM channel through a series resistor.

Schematic

68

69

Code

int ledPin = 9;
void setup()

The for loop increments the fadeValue from 0 bis 255


(lightValue++ keeps adding 1 to the variable). The
analogWrite command sends this value to the LED. It will
increasingly grow brighter.

pinMode(ledPin, OUTPUT);
}
void loop(){
for (int lightValue=0; lightValue<=255; lightValue++){
analogWrite(ledPin, lightValue);
delay(2);
}

The second for loop decrements the fadeValue from 255


to 0 (lightValue keeps counting the variable down
by 1). The LED will grow dim again.

for (int lightValue=255; lightValue>=0; lightValue--){


analogWrite(ledPin, lightValue);
delay(2);
}
}

Output graph
Pin 13
5V
0V
0s

70

0,25s

0,5s

0,75s

1s

The voltage rises


to 5V, then falls
back to 0V. (As
mentioned on the
previous page, this is
done through rapid
switching between
the on and off
positions PWM).

Exercise
1. Do the same in reverse with a
second LED on another pin. Make
sure it's a PWM pin.

Solved

Solution:
Sketchbook/Fritzing Creator Kit/ Exercise6_1

71

#7:

Night Light

Difficulty: medium

Circuit: Fritzing / Nightlight.fzz


Code: Sketchbook/Fritzing Creator Kit/Nightlight

The next project is a night light that slowly changes its


colour. An RGB LED is used for this.
An RGB LED is an LED package in which three LEDs (red,
green and blue) are embedded. They share one common
leg. The shared leg in the kit's RGB LED is the cathode
(negative). The three remaining leads (anodes) are each
assigned one colour. Each built-in LED requires its own
series resistor.
For a good colour combination, wrap a piece of white
paper around the LED, or stick it into a ping pong ball
(drill a 5mm hole).
Find the programming explanation in the programming
code of the example.

red
cathode (-)
green
blue

Fritzing diagram

Schematic

72

73

Electronic Basics 3:

Amplification
Fritzing diagram

Preparing a motor
cable: (1 Carefully cut
the cable insulation
with a knife and pull
it off (2), form the
wire ends by twisting
the strands (3) and
plug them into the
extension cords
(4) to connect the
motor.

Basically, the Arduino board is a control unit. It supplies


each channel with a current of 40mA. This is sufficient
for smaller loads such as LEDs. For larger loads (such
as motors, solenoids or valves), an additional electronic
switch is required to conduct larger currents.
This electronic switch is a transistor. A field effect
transistor (FET N-Chanel) is included in the kit. It has
three terminals: Gate, drain and source

2
MOSFET
Gate
Drain
Source

Schematic

Source is connected to GND, drain connected to the load


(for example, the motor). When a positive voltage (HIGH)
is supplied to the gate, the current flows between drain
and source. As a transistor switches with great speed, it
can also amplify PWM signals.
The example shows a circuit with a separate power
supply. GND of the power source must be connected to
GND of the Arduino. The code from the blink or fading
examples can be used for this. The pin from the blink
example must be changed to pin 9.

74

75

Motor Control with


an H-Bridge

In the section Electronic Basics 3: Amplification, you used a


transistor to control a motor. With this technique you can
control the speed of a motor, but not the direction of its
rotation.

Circuit: Fritzing / H-Bridge.fzz


Code: Sketchbook/Fritzing Creator Kit/ Motor

Fritzing diagram
*

Integrated Circuit

It's a chip in which


different components are built into a
small space.

Controlling one
motor

An easy way to make electric motors rotate in both


directions is by using an H-bridge. This is an IC* that is
optimised for its use as a motor driver (L293D). It can
control two motors independently.
The illustration shows a motor controlled by the Arduino.
The power is supplied by a battery, though of course a
mains adaptor may also be used. If the motors are small
(eg vibration motors), they can be powered directly from
the Arduino. To do this, you only have to connect the
orange wire of the H-Bridge to the circuit's +5V pin.

A notch or a
dot are used to identify

16 15 14 13 12 11 10

the orientation of an IC.

L293D
1

Fritzing diagram

The H-Bridge L293D can handle a brief current of 1.2A


(PEAK), and a continuous current of 600mA per channel.

Controlling two
motors (there is
only one motor in
the kit)

76

A major advantage of the L293D are the integrated


flyback diodes, which retain the induced current that
forms when the motor is still turning but switched off
(http://en.wikipedia.org/wiki/Flyback_diode).

77

Code

int motor_A=6;
int motor_B=5;
int motor_Speed=3;
void setup(){
pinMode(motor_A,OUTPUT);
pinMode(motor_B,OUTPUT);
}
void loop(){
digitalWrite(motor_A,HIGH);

Determines the direction of the


motor's rotation.

digitalWrite(motor_B,LOW);
for (int i=0; i<256; i+=5){
analogWrite(motor_Speed,i);
delay(20);

Rotation speed increases from 0


255, then it decreases again to 0.

}
for (int i=255; i>0; i-=5){
analogWrite(motor_Speed,i);
delay(20);
}
digitalWrite(motor_A,LOW);

Rotation direction is reversed.

digitalWrite(motor_B,HIGH);
for (int i=0; i<256; i+=5){
analogWrite(motor_Speed,i);

Rotation speed increases again from


0 255, then it decreases again to 0.

delay(20);
}
for (int i=255; i>0; i-=5){
analogWrite(motor_Speed,i);
delay(20);
}
}

78

79

5. Analog
Input

In this chapter:
you will understand how a potentiometer
is built and how it works.
you will be introduced to a reference resistor.

ana | log :
whatever can assume
a range of different
states, such as pressure,
brightness, temperature
or angle of rotation

in | put :
external influences that
can be interpreted
by the Arduino board,
such as the angle of
a potentiometer, or
reading sensors for light,
humidity, or temperature

you will develop an automatic


lighting system for cars.
you will reproduce a classic game.

#8:

Potentiometer

Difficulty: medium

Circuit: Fritzing / Potentiometer.fzz


Code: Sketchbook/Fritzing Creator Kit/Potentiometer

If you bend the three


legs of the potentiometer to 90, it will
be easier to plug into
the breadboard.

A potentiometer is a variable resistor. It is made of


an arc-shaped resistive element that is electronically
divided into two parts by a wiper. Moving the wiper on
the resistive element changes the proportion of the
resistance on each side of it. This proportion is read by
the Arduino board to determine the position.
When compared
with
the 8 bit PWM output
(see page 67) the resolution of an analog
input is higher:
210 = 1024 states, or
0 1023.
*

The outer leads of the potentiometer are connected to


+5V and GND, the centre lead to an analog input.
Values are read between 0 and 1023*. In the circuit
example above, this value is converted to the value range
of 0 255 with the map function, and transmitted to an
LED as analog output (PWM).

Fritzing diagram

Schematic
resistive element
wiper (or tap)
partial resistance 1

partial resistance 2

+5V
analog
GND

82

83

Code

int ledGreen = 6;
int ledRed = 5;
int potPin = 0;
void setup(){
}
void loop () {
int value = analogRead(potPin);
int redValue = map(value,0,1023,0,255);
int greenValue = map(value,0,1023,255,0);
analogWrite(ledRed,redValue);

map
The map() command converts an incoming value from
one value range to another. In this case, the value range
of the analog input (0 to 1023) is converted to the range
of the analog output (0 to 255).

analogWrite(ledGreen,greenValue);
}

84

85

Electronic Basics 4:

Reference Resistor
The analog input on the Arduino board converts a voltage
between 0 and 5V to a value from 0 to 1023 (10-bit
analog-to-digital converter). To be able to measure this
voltage, a reference resistor is needed for sensors such
as photoresistors. The reference resistor is connected
in series with the sensor. One side of the circuit is
connected to GND and the other side to +5V. The line
that connects both is hooked to the analog input.

in

in V

I in A
10A

COM

Fritzing diagram
Connecting a potentiometer.

An E-series is
a mathematical
sequence of
calculated values.
*

Fritzing diagram

Connecting a
photoresistor and
its corresponding
reference resistor.

You can either try it out or calculate the value for the
reference resistor. To calculate it, you have to measure
the minimum and maximum resistance with a meter.
For example, if you want to use a photoresistor, then
measure its resistance in both its darkest and brightest
situations. Now add both values and divide the sum by
two. The result is the ideal reference resistor value. Since
resistors aren't available with every value (E series*),
simply use the value closest to the one you need.

Formula

Rref =

86

(Rmin + Rmax) / 2

87

#9:

Automatic Lighting System

A light dependent resistor (LDR) or photoresistor is made


of a material that changes its resistance in proportion to
the intensity of the light it is exposed to. The more light
that falls on it, the lower the resistance. In our example,
we will take advantage of this capability to automatically
turn on the headlights of a car.

Difficulty: medium

Circuit: Fritzing / AutomaticLightingSystem.fzz


Code: Sketchbook/Fritzing Creator Kit/AutomaticLightingSystem

The photoresistor leads are very long. Make sure that


there is no contact between them.

Serial interface
To find out the LDR's
resistance values you can
use the serial port.
The serial port provides
a data link between
the Arduino and your
computer. It is initialised in
setup with the command

Fritzing diagram

Schematic
Arduino software
serial monitor

Serial.begin(baudrate);. The baud rate is the


transmission speed, which can be 9600, 28800, 57600, or
115200 bits per second.
After it is initialised, you can send data to the serial port
with the command Serial.println(value); The
data may consist either in variables or text. Open the
serial monitor in Arduino software: Tools > Serial Monitor.
This is where the files are shown. The baud rate must be
the same as in the code. You can adjust it on the bottom
line of the serial monitor.

88

89

long

Code

int lightsensorPin = 0;
int headlightsPin = 2;
int switchingthreshold= 300;
int wait = 1000;
long timer = 0;
int value;
void setup(){
Serial.begin(9600);
pinMode(headlightsPin,OUTPUT);
}

The variable type long is similar to int, but it lets you


process larger numbers. These are needed to set the
timer.

Serial.begin(baud);
starts the serial communication.

Serial.println(daten);
sends the contents of the variable value to the serial
port.

timer

void loop(){
value = analogRead(lightsensorPin);
Serial.println(value);
if (value<switchingthreshold){
timer=millis();
digitalWrite(headlightsPin, HIGH);
} else if (millis()>wait+timer){
digitalWrite(headlightsPin, LOW);
}

When the intensity of the light is less than the switching


threshold, the light is switched on and a timer variable
(timer) is set to millis(). The command millis()
returns the number of milliseconds that have elapsed
since the last Arduino reset. As soon as the light intensity
is greater than the switching threshold again, it checks
whether the current milliseconds is greater than the sum
of the timer variable plus the waiting time (in other words
it checks whether the waiting time has passed). If so, the
headlamps are switched off again.

delay(10);
}

90

91

#10:

Ping Pong

Difficulty: hard

Circuit: Fritzing / PingPong.fzz


Code: Sketchbook/Fritzing Creator Kit/PingPong

You can also create a simple but exciting Ping Pong game
with the Arduino. The LED display is connected as in the
matrix example. In this case, two potentiometers are
added as game controllers.

Fritzing diagram

Schematic

Text on matrix on
this side.

+
To bridge longer
distances you can
simply connect two
wires.

92

93

6. Servomotor,
Sound

In this chapter:
you will learn all about the structure
and functions of a servomotor.
you will build a robot.

Ser|vo|mo|tor:
converts electrical
signals into motion
can be rotated
from 0 180

Sound:
a complex acoustic event
in the Arduino
environment, the
conversion of
electrical signals into
mechanical vibrations

you will generate sounds with


your own synthesizer.
the Arduino board will be powered by a battery.

#11:

Servo

Difficulty: medium

Circuit: Fritzing / Servo.fzz


Code: Sketchbook/Fritzing Creator Kit/Servo

Fritzing diagram

potentiometer to
control the angle

gear
connection cable

motor control unit


electric motor

Schematic

The housing of a servomotor contains an electric motor,


an electronic control unit to determine the position, and
a gear system for high performance. The servo axis can
be rotated to 180.
The servo motor has a cable with three wires. The red
wire in the middle must be connected to the +5V, the
brown (or black) to GND and the orange (or yellow) to a
digital pin on the Arduino. It is important to connect the
servo correctly, otherwise it will be damaged.
96

97

Library

Code

#include <Servo.h>
Servo myservo;
int potpin = 0;
int val;
void setup()
{

A library (program library) extends the range of


commands to include special functions, such as, in this
case, servo control. A library is composed of one or more
files. It is integrated with #include.
The method myservo.attach(9) connects the servo
functionality to pin 9.
The method myservo.write(val) positions the servo
to val, whereby the value of val should be between 0
and 179. Therefore, the servo can be rotated 180.

myservo.attach(9);
}
void loop()
{
val = analogRead(potpin);
val = map(val, 0, 1023, 0, 179);
myservo.write(val);
delay(15);
}

Paper cut -out model


You will receive a small
application for the servo
with the paper cut-out
model "Robots". Enjoy :)

98

99

#12:

Synthesizer

Difficulty: medium

Circuit: Fritzing / synthesizer. fzz


Code: Sketchbook/Fritzing Creator Kit/Synthesizer

We can use a Piezo speaker to generate sounds. It


converts electrical frequencies into sound waves.
Different sound waves are produced by rapidly switching
the voltage on and off (pulse).

Fritzing diagram

Here we will begin with something a bit more complex


we'll build a Piezo synthesizer. The program text
processes two parameters, which are read from two
potentiometers. One potentiometer affects the pitch
level, the other the duratioin of a continuous repeated
loop.

Schematic

100

101

Code

int buzzerPin = 8;
int potPin1 = 0;
int potPin2 = 1;
int toneHeight, lfo;
void setup() {
pinMode(buzzerPin, OUTPUT);
}
void play(int myPitchLevel) {
digitalWrite(buzzerPin, HIGH);
delayMicroseconds(myPitchLevel);
digitalWrite(buzzerPin, LOW);
delayMicroseconds(myPitchLevel);
}
void loop() {

your own method


The play() method is your own method. Own methods
are always useful when a task has to be processed over
and over again. In this case, an argument is passed and
is available within this method under the variable name
myPitchLevel. It is called up with play(value).

toneHeight=analogRead(potPin1);
lfo=analogRead(potPin2);
for (int i = (lfo/10); i > 0; i--) {
play(toneHeight);
}
delayMicroseconds(lfo);
for (int i = 0; i < lfo/10; i++) {
play(toneHeight);
}
}

102

103

Battery
Fritzing diagram

To operate the Arduino board with a battery, you can


either connect the battery to the DC power jack with an
adapter, or connect it directly to GND and the Vin pin.
In the latter case, you should pay attention to the
correct polarity, otherwise the Arduino could be
damaged. The Fritzing Creator Kit includes a 9V
battery clip, with a black and a red wire. The red wire is
connected to the positive pole of the battery and must
be plugged into the Vin. The black cable is GND, and is
connected to the GND pin.

Preparing the 9V-clip


wires: Carefully cut
the wire insulation
with a knife, then
pull it off.

You can fasten the battery with self-adhesive Velcro or


double-sided tape on the base plate.

Fritzing diagram

104

105

7. Arduino
meets
Processing
Ar | du | i | no:
Physical Computing
Platform
lets electronic projects
come alive

Pro | cess | ing:


Java-based programming
language
perfect for creative ideas

In this chapter:
you will control an LED with the
Processing software.
you will use a potentiometer to draw
on a virtual magic drawing board.
you will build a dinosaur that notifies
you of incoming Twitter news.

Preparing the Arduino

Firmata

Open the Arduino software program


and transfer it
to the Arduino board. Arduino is now ready for use in
Processing and does not need to be reprogrammed.

File > Examples > Firmata > StandardFirmata

Firmata is a protocol for the communication between


a microcontroller (such as the Arduino) and software
running on a computer. A protocol can be considered
as a language with which two different systems can
communicate.

Installing Processing
We tested the
Firmata support for
Processing 1.5.1 and
2.1 at the time of
printing this booklet

In the following section we will let an Arduino and the


Processing software "talk" to each other.

Processing library:
Firmata

Processing is particularly well suited for programming


generative graphics, animations, and interactivity.

Install the Firmata library for Processing.

Arduino code:
Examples/Firmata/
StandardFirmata

Processing code:
e.g. Processing/RGB

Processing is a Java-based, open programming


environment. Download at www.processing.org. Please
download a 2.x version and install it for further use.

To prepare Processing for Arduino, a few more steps are


still needed:

RX0

10

11

12

13

DIGITAL (PWM= )

ICSP2

TX0

RESET

GND

Firmata

AREF

1. Download the Firmata program library for your


version of Processing:
http://playground.arduino.cc/interfacing/processing
L
TX
RX

ON

TM

Arduino

Processing Software

Arduino board

A5

A4

A3

A2

A0

ANALOG IN
A1

VIN

GND

GND

5V

POWER
3V3

RESET

IOREF

ICSP

2. Open the Processing Sketchbook folder. (You will


find the path if you go to Processing and click on
Processing > File> Preferences.)
3. If the Sketchbook folder still hasn't got a libraries
folder, create one yourself. Pay attention to the
spelling: libraries.
4. Then copy the Firmata program library into the
folder.
5. The library will be automatically loaded when you
run Processing.

108

109

Preparing the circuit

#13:

Build the following circuit (Processing RGB see below).

Processing RGB

Datei: Processing_RGB.fzz
Code: Beispiele/Firmata/StandardFirmata
Processing code: Processing/RGB

Open program example


You will find the folder Processing in the Fritzing Creator
Kit software package you have downloaded. Open the RGB
file from the Processing folder.
Start up the program Sketch > Run.

Selecting the port


The Processing window has a black output area at the
bottom. When the program is launched, all connected
devices are displayed. Remember the number that
appears at the beginning (e.g.: 0) of the line referring
to the Arduino. On a computer running Windows, it is
usually the last entry (eg COM3), on a Mac it is the first
or the last entry (z.B. dev/tty/usbmodemfa141). Close the
program, and insert the number into the program code
line: myArduino =
new Arduino(this, Arduino.list()[0], 57600);
Restart the program Sketch > Run.

Find the programming explanation in


the code.

Fritzing diagram

Screenshot
Processing
Processing
The Processing
software probably
looks very familiar
to you. The Arduino
software is modelled
after it.

110

111

#14:

Magic Board

Difficulty: medium

Circuit: Fritzing / Magic Board . fzz


Code: Beispiele/Firmata/StandardFirmata
Processing code: Processing/Magic Board

Fritzing diagram

Screenshot Processing

Inspired by the legendary Etch-A-Sketch, two knobs are


used to move a drawing tool in the X and Y directions on
the computer screen. If you want to draw a new picture,
simply shake the base plate and the canvas will be
"emptied".
As we have seen in the previous example, the program
StandardFirmata must first be installed on the Arduino
board.
You'll have to select the right port in Processing
again (see page 108, Select Port).
112

113

#15:

TwitterSaurus

Difficulty: hard

Circuit: Fritzing / TwitterSaurus . fzz


Processing code: Processing/TwitterSaurus

Fritzing diagram

You will find a paper


cut-out model of
the dinosaur in the
Creator Kit.

This is how to obtain your access data:


1. Go to https://dev.twitter.com/apps/new and login
with your user name and password.

Twitter Saurus is a program that displays a tweet


whenever that tweet contains a certain search term. In
addition, the Twitter Saurus will open its mouth and emit
a sound.
Extend the servo cable to the length you need. As in the
Firmata example, the StandardFirmata program must
previously be installed on the Arduino for this.
We still need to prepare a few things. The Twitter Saurus
program for Processing uses the Twitter API. It enables
people to develop their own programs around Twitter.
For security reasons, an OAuth authorization is necessary
for this.
114

2. Fill out the "Create an application" form you are


free to choose the name, description and website.
3. Confirm the terms and conditions, fill in the captcha
and click on Submit.
4. On this page you will find the Consumer key and
the Consumer secret. Save them to a text file.
5. N
ow, click on Create my access token.
Save both token values Access token and
Access token secret.
6. Open the TwitterSaurus file in Processing, and copy
the four valuesinto the setup method.
115

8.

From
prototype to
product

In this chapter:
you will learn about the usefulness of
PCBs for you and your projects.
you will develop your first circuit layout.

pro | to | type:
model created from
a project idea
usually unique

pro | duct:
finished result
project that can
be produced on
a large-scale

you will get to know the methods used for


mounting components on circuit boards.

Fritzing
Our "Fritzing Fab service (http://fab.fritzing.org) offers
you the possibility to have your PCBs produced either
individually or in larger quantities. This way, you can
easily transform your project's breadboard-based
prototype into a professional product at a reasonable
price.

Fritzing is a project that aims to make the creative use of


interactive electronics accessible to everyone. We want
everyone to be able to realize their own ideas quickly and
easily, from initial sketch to finished product.
The centerpiece of the Fritzing project is the free
Fritzing software, enabling you to document projects
in a clear and intuitive way. Furthermore, the
software makes designing your own professional
printed circuit board an easy task. Simply download it
at http://fritzing.org/download .

And what's more: The Fritzing team is very


active and offers many workshops. Visit us at
http://fritzing.org/events, we just might be in your area.

Fritzing has become a standard, and a considerable


number of creative electronics projects are available in
a variety of books and websites that will make it easy for
you to learn and invent. You will also find an extensive
project gallery on the Fritzing website http://fritzing.org
where users meet to share, discuss and develop their
creations together. Of course you will also find video
tutorials there, and further assistance.
The Creator Kit you have in your hands now is not just
a great starter kit for interactive electronics. By buying
it, you are also encouraging us to keep developing and
improving our our product since all profits are returned
to the Fritzing project. Thank you!

Screenshot of the
free Fritzing software

118

119

PCBs

Composition of a circuit board

Although breadboards are very convenient for designing


projects, they are quite fragile and especially dont
travel very well. This is where printed circuit boards
(PCBs) come in handy. They provide a strong mechanical
attachment for parts and stable electrical connection of
electronic components. The wiring is realized by means
of copper traces. PCBs are also used to turn a project idea
into a real product (for example, the Arduino itself).

components

silk screen
position and names of
components,
info or decoration

solder resist (front side)


covers traces and protects
against corrosion and
misplaced solder

The PCB production process


can be divided into three parts:

solder mask
determines the areas to be
tinned for soldering of
components

PCB layout
PCB production
assembly

copper layer (front side)

It is quick and easy to create the PCB


layout with the Fritzing software.
But professional PCB manufacturing is a highly complex process.
There are many PCB manufacturing services available, but we have introduced our own
Fritzing Fab service to make it as easy as possible to go
from a PCB layout--created using the Fritzing software--to
a finished professional PCB.
Assembly is the process of attaching parts to a board.
This can be done by hand (soldering) or by machine.
The latter is especially appropriate in mass production.
To minimize the costs in mechanical assembly, SMD
components should be used. We will be happy to make
you an offer: fab@fritzing.org
120

vias
connection between upper and
lower copper layer

Circuit board
produced with
Fritzing Fab (see
page 125)

carrier material
such as fiber reinforced
plastic
copper layer (back side)

solder mask (back side)

solder resist (back side)

silk screen printing (back side)

121

PCB layout
It is very simple to layout a PCB with Fritzing. Let's start
with the Fortuneteller example. First, change to the PCB
view: View > Show Circuit Board.

Fritzing diagram

The green surface represents the circuit board. You


can resize it with the drag and drop function by clicking
the corners, or select an alternative shape from the
information window, for example Arduino Shield."

Now you can start arranging the components. It's best


to begin with the pins for the Arduino. Move them until
they more or less match the marked position. Then click
on the board and, in the information window, disable
the "Sticky" function. This allows you to slide the board
exactly under the pins.
122

123

The remaining components can now be arranged. Ideally,


the lines connecting the pins should intersect as little as
possible.
Change the LED labels that are appropriate for a fortuneteller's response. Once an LED is marked, you can also
move its label.

The autorouter suggests trace paths that you can, and


sometimes even must, change. You can add a bendpoint
to the traces by dragging on a trace at the place at which
you would like to add the bendpoint. Traces in yellow
are on the board's upper side, traces in orange on the
underside. You can "move a trace to the other side of the
board" by right clicking it.

Now call up the Autorouting feature in the menu under


Routing.

After this, you can still add logos and text to the board.
You can find these elements in the components library.

124

125

By selecting Routing > Ground Fill from the menu you can fill
the blank areas with copper. The ground fill is connected
with GND on the PCB (this reduces electromagnetic
interference on the board), whereas the copper fill stays
electrically isolated from the rest of the circuit.

If everything is OK, you'll get a message confirming that it


is ready for production. To produce the circuit board, you
can export it in the Gerber format, or manufacture it with
Fritzing Fab.

Fritzing Fab
Fritzing Fab (fab.fritzing.org) is our production service
for printed circuit boards. We have them produced in
a professional PCB factory. The number of parameters
influencing PCB production is quite large Fritzing
automatically chooses a good set of defaults. To
see what the PCB would cost you, simply click on
Routing>Fritzing Fab Quote in the Fritzing software.
Finally, the components still have to be soldered.
Use the Design Rules Check (DRC) from the Routing menu
to check the layout at the end. It will find errors such as
trace overlaps.

Finished board

126

127

Mounting the components


There are two methods used for mounting components
on a circuit board:

THT (Through-Hole Technology)

In THT, the components to be mounted have leads. That


is, they have a long terminal ends (legs) that are inserted
into the holes in the printed circuit board and are
normally soldered at the back. Holes are plated through
from top to bottom, which means they are lined with
copper. Components are relatively large, but they also
withstand greater mechanical stress, which can be an
advantage in connectors.

SMT (Surface-Mount Technology)

In surface mounting, the components (also called SMD,


Surface Mounted Device) are soldered onto pads on the
surface of the board; or, alternatively, in a process called
reflow, they are attached to the circuit board with the
help of solder paste, which melts in the reflow oven. This
method need considerably less space than the throughhole technology; however, traces cannot run underneath
components, which requires jumping a trace from one
side of the board to the other. When a trace jumps from
the top to the bottom of a board, the connection between
the top and bottom is called a via.
SMD components are available in different sizes. The size
designates the edge length. 0805 means that the length is
08 1/100 inch (about 2 mm, while the width is 05 1/100
inch (about 1,25 mm).

128

THT component
(resistor)

solder joint

metal
lead

1
SMD component
(resistor)

VIA

trace

129

Troubleshooting

Goal achieved!

Should you have problems while working with


the kit, please visit our troubleshooting page at:
fritzing.org/forum/creatorkit/troubleshooting.

Congratulations! You've reached the end of this booklet.


Now you know what an LED is, and how to turn it on and
off. You've blinked an SOS, read push-buttons, had your
future told and found out how headlights are switched on
in modern cars. You've built robots, and dinosaurs have
read your Twitter stream.
I hope the journey was fun, and that now your head is full
of ideas that you want carry out. Although it's the end of
the booklet, it's by far not the end of the possibilities that
Fritzing, Arduino and Co. has in store for you.
I'm already looking forward to your projects. Please share
them in the Fritzing project gallery:
www.fritzing.org/projects.
Should you have any questions, please visit our forum:
www.fritzing.org/forum. In the category CreatorKit you will
quickly find help. Of course you are also invited to answer
other users' questions. After all, you're an Arduino expert
now!

130

131

Acknowledgements

Imprint

At this point I would like to thank everybody who has contributed to


this booklet. My thanks goes to:

Concept & Text

The explanations in this booklet were

Stefan Hermann

created and tested to the highest


standards of quality. Nevertheless,

Clemens Gruber, Clemens Winkler, Loris Bottello, Martin Kim Luge,


Mey Lean Kronemann, Naomi Knopf, Stella Morelli, Tommaso
Bertagnin and Valeria Sanguin, for their inspiring projects;

Design &

we cannot rule out errors. Should you

Typesetting

notice anything, please write to us:

Christian Ivanis

www.fritzing.org/forum/creatorkit.

Carsten Niehaus, Christian Benedict, Claudius Lazzeroni, Clemens


Gruber, Detlef Meiner, Frank Trger, Franz Klein-Reesink, Hubertus
v. Frstenberg, Sabine and Christian Aschoff as well as Thomas
Sturm, for their feedback to the first prototype of this booklet.

Fonts

All information in this booklet is subject to

OCR A Tribute,

change.

Droid Sans
Fritzing
Illustrations

Thanks to Jonathan Cohen for checking the English translation!


Volker Bombien from O'Reilly Media, for his comments on the
booklet.

a business division of

Stefan Hermann
Fabian Althaus

IXDS GmbH

Dirk v. Oosterbosch

Paul-Lincke-Ufer 39/40

Fritzing Software

10999 Berlin
District Court

I would like to thank the entire 2013 Physical Computing course of


the Potsdam University of Applied Sciences (FH Potsdam), under the
direction of Professor Reto Wettach, for testing the first Kit Creator
prototype, and in particular Anita Meier.

Fritzing Team

Berlin-Charlottenburg

Amgad Keshki

Commercial Register: HRB 118950

Amin Zayani
Andr Knrig

www.fritzing.org

Anna Heib

I am also indebted to Elena Dieckmann, who has made me realize


that what we are doing here is really some awesome stuff!
I thank the entire Fritzing and IXDS team, especially Amin Zayani for
his help in planning the kit, Christian Ivanis for his magnificent layout
work, Patricia Hegglin and Nushin Isabelle Yazdani for testing and
proofreading. Also, I thank Reto Wettach and Andr Knrig whose
original vision we are now realising here.

Christin Rothe

Fritzing is a trademark of

Daniel Clerc

Friends-of-Fritzing e.V.

David Elsche

Amtsgericht

Fabian Althaus

Berlin-Charlottenburg

Hans Kadel

VR-Nr: V30985B

Jonathan Cohen
Monique Mathieu

cc - by - nc - nd

Niklas Dnger

2014 Fritzing

Reto Wettach

And I thank you! You've bought the kit and taken your first steps
with it. Onward and upward!

132

Sevgi Ulas
Stefan Hermann

Made with

Friends of

133

14

20

Fr
it
z

g.
or
g

in

Vous aimerez peut-être aussi