Anda di halaman 1dari 44

Elexhub

TABLE OF CONTENTS Page 2 of 44

• Lesson 5: LED Fade


• Introduction • Lesson 6: LED Fade with
3 18 Potentiometer
• Kit Contents
• What is Arduino? • Lesson 7:Light Sensing Circuit
• Arduino IDE • Lesson 8: Seven Segment
• Arduino Hardware • Lesson 9: 4-Digit Seven Segment
Display

• Lesson 1: Blink • Lesson 10: Tilt-Activated LED


• Lesson 2: Button • Lesson 11: IR Remote Control
Controlled LED • Lesson 12: Dot LED Matrix
• Lesson 3: Introduction to • Lesson 13: Reading the Room
Buzzers Temperature
• Lesson 4: Knight Rider • Lesson 14: RGB Color Display
Introduction Page 3 of 44

Elexhub, with its desire to be able to help its valued customers,


introduces you to this Arduino Basic Starter Kit 2 Manual. This is Elexhub’s
second release for an Arduino Basics manual. This manual serves as a
convenient, easy to use reference for your every Arduino query. Like the
previous version, it begins with the basic structure of the Arduino Hardware
as well as its Software, the Integrated Development Environment (IDE). The
manual includes basic lessons and examples that may guide you in learning
the whereabouts of an Arduino. This manual shows you how to use most of
the components in the kit and give you software sketch examples for each
one. This manual walks you through the basics of using the Arduino in a
hands-on way.

May this book be a huge learning experience for you. Remember, you
can build a LOT of cool things with an Arduino, the examples in this manual
are just the beginning. Good luck and have fun!
Kit Contents Page 4 of 44

Jumping Wires 1 Digit Seven Segment Display

30 pieces of variable length A seven-segment


1 set short electrical wire with a solid 1 pc display (SSD), is a form of
tip at each end which is normally electronic display device for
used to interconnect the displaying decimal numerals.
components in a breadboard.

Solderless Breadboard
A 830-points protoboard used Tact Switch
for electronic circuit building.
This is the construction base for A 4-pin tactile electro-
1 pc prototyping electronics where 4 pcs mechanical switch used to
we place our components and close a circuit once pressed.
create temporary prototypes or
circuit design.

Buzzer
Light Emitting Diodes(LED)
1 piece each of an active and
15 pieces of assorted colored
15 LEDs that emits lights used to 2 pcs passive buzzer used as an
audio-signaling device. It
pcs indicate presence or absence of
creates sound once provided
electric current.
with electrical signal.
Kit Contents Page 5 of 44

Resistors
Battery Holder with Power
23 pieces each of 10k (5), 1k (5) Jack
and 220 (8) ohms resistor that
23 acts to reduce current flow and
1 pc
This is a 6x AA battery holder
pcs lower voltage levels within with power jack that hold
circuits. They help protect batteries.
electronic components.

Potentiometer UNO R3 with FREE CABLE

A 10k ohm single-turn three- An Arduino is an open-source


terminal resistor with a sliding or 1 pc prototyping platform based on
1 pc rotating contacts that is used to (optional) easy-to-use hardware and
form an adjustable voltage software.
divider.

Ball Switch
4-Digit Digital Tube
A tilt sensor that can detect
This is a basic 4-digit 2 pcs basic motion/orientation. The
1 pc 7-segment display. The display
metal tube that has a little metal
features one decimal point per
ball that rolls around it.
digit.
Kit Contents Page 6 of 44

Photoresistors
LM35 Temperature Sensor
Also called Light Dependent
Resistor (LDR) is a light- This device measures
3 pcs controlled variable resistor. The
1 pc
temperature with an electrical
resistance of it decreases with output proportional to the
increasing light intensity. It temperature.
exhibits photoconductivity.

Flame Sensor 74H595

A flame sensor detects and This is an 8-bit serial-in/serial or


responds to the presence of 1 pc parallel-out shift register with a
1 pc flame or fire. storage register and 3-state
outputs.

RGB LED Module


Infrared Receiver Sensor
This module consists of a plug-in
An infrared receiver is 1 pc full color LED made by R, G, B
1 pc hardware that sends information
three pin LED.
from an infrared remote control
to another device by receiving
and decoding signals.
Kit Contents Page 7of 44

8x8 Dot Matrix

A LED Matrix is a
display component used to
1 pc create patterns and messages
using an 8x8 LED display.

Remote Control

This a universal infrared remote


control with controlling distance
1 pc up to 8 meters.
What is Arduino? Page 8 of 44

An Arduino is an open- Arduino is born at the Ivrea


source prototyping platform Interaction Design Institute as
based on easy-to-use hardware an easy tool for fast
and software. It is able to read prototyping, aimed at students
different forms of inputs and without background in
turn it into a desirable output. electronics and programming.
By sending a set of instructions As soon as it reached a wider
using codes on its IDE, you can community, the Arduino board
tell the board what to do. started changing to adapt to
new needs and challenges.

Arduino UNO is the best board to get started with electronics and coding. If this is your first
experience on programming with the platform, the UNO is the most robust board you can start
experimenting with. The UNO is the most used and documented board of the whole Arduino family.
Arduino Integrated Development Environment (IDE) Page 9 of 44

The open-source Arduino Software (IDE) makes it easy to write code and upload it to the board. It
runs on Windows, Mac OS X, and Linux. The environment is written in Java and based on Processing
and other open-source software.

Writing Sketches Sketchbook

Programs written using Arduino Software (IDE) are The Arduino Software (IDE) uses the concept of a
called sketches. These sketches are written in the text sketchbook: a standard place to store your
editor and are saved with the file extension .ino. The editor programs (or sketches). The sketches in your
has features for cutting/pasting and for sketchbook can be opened from the File >
searching/replacing text. The message area gives Sketchbook menu or from the Open button on the
feedback while saving and exporting and also displays toolbar. The first time you run the Arduino software,
errors. The console displays text output by the Arduino it will automatically create a directory for your
Software (IDE), including complete error messages and sketchbook. You can view or change the location of
other information. The bottom right hand corner of the the sketchbook location from with
window displays the configured board and serial port. The the Preferences dialog.
toolbar buttons allow you to verify and upload programs,
create, open, and save sketches, and open the serial
monitor.
Arduino Integrated Development Environment (IDE) Page 10 of 44

Verify Open

Checks your code for errors before Presents a menu of all the sketches in
compiling it. your sketchbook.

Upload Save

Compiles your code and uploads it to Saves your sketches.


the configured board.

New Save

Creates a new sketch. Opens the serial monitor.


Arduino Hardware Page 11 of 44

4. ATmega microcontroller- The heart of your board.

5. Analog pins- Use these pins with analogRead().

6. GND and 5V pins- Use these pins to provide +5V power and
ground to your circuits.

7. Power connector- This is how you power your Genuino when it’s
not plugged into a USB port for power. Can accept voltages between
7-12V.

Here’s the anatomy of an Arduino Uno. 8. TX and RX These LEDs indicate communication between your
Genuino and your computerLEDs- . Expect them to flicker rapidly
1. Digital I/O pins -Use these pins with digitalRead(), during sketch upload as well as during serial communication. Useful
digitalWrite(), and analogWrite(). analogWrite() works for debugging.
only on the pins with the PWM symbol.
9. USB port- Used for powering your Genuino Uno, uploading your
2. Pin 13 LED- The only actuator built-in to your board. sketches to your Genuino, and for communicating with your Genuino
Besides being a handy target for your first blink sketch, sketch (via Serial. Printing () etc.).
this LED is very useful for debugging.
10. Reset button- Resets the ATmega microcontroller.
3. Power LED- Indicates that your Genuino is receiving
power. Useful for debugging.
Lesson 1: Blink Page 12 of 44

Description: Circuit Explanation:


Blinks LED with a pre-defined delay.
In this circuit we only have two electronic components
Components: other than arduino board. So it is pretty simple. Lets see what does
•Arduino Uno board what
•Solderless breadboard Positive pin of the LED connect to the arduino digital pin 10.
•LED As you can see a 220Ω resistor is connected to the led in series. We
•Resistor call that resistor a “Current Limiting Resistor” What does it does?
•Jumper Wires Well , as you might know most LEDs work the voltage
range of 2.2V – 3.0V and current range of 20mA – 50mA. Arduino
Connection: Uno is giving a output of 5V, when this much of voltage applied
across the LED, about 250mA(V=IR) will flow through the LED this
will cause the led to burn. So what this resistor does is keep the
voltage across the LED within it’s working range And by doing so
keep the current lower than maximum limit.
Lesson 1: Blink (Code Discussion) Page 13 of 44

So the process of the code is very simple,


•Give our output pin a name - int led = 10;
•Configure the pin as a output - pinMode(led, OUTPUT);
•Turn on the led - digitalWrite(led, HIGH);
•Wait for 1 second - delay(1000);
•Turn off the led - digitalWrite(led, LOW);
•Wait for 1 second - delay(1000);
Lesson 2: Button-Controlled LED Page 14 of 44

Connection:

Description:
Keeps the LED on as long as the button is
pressed.

Components:
•Arduino Uno board
•Solderless breadboard
•LED
•Resistor
•Jumper Wires
•Button Switch
Circuit Explanation:

The LED is controlled with a current limiting resistor as in


Lesson 1. The button switch is connected with a resistor too. This
connection is called a pull down resistor. This is used to connect the
arduino’s GND pin when the button is not pressed, called a floating
pin.
Lesson 2: Button-Controlled LED(Code Discussion) Page 15 of 44

Pins are assigned and configured as in the earlier


tutorials . In the loop we read the button pin status and assign
it to Boolean variable called button_state. Then led pin is
write according to this variable
Lesson 3: Introduction to Buzzers Page 16 of 44

Description:
In this lesson, we will create some sound using
Arduino and buzzers.

Components:
•Arduino Uno board
•Solderless breadboard
•Passive Buzzer
•Active Buzzer Circuit Explanation:
•Jumper Wires
In this circuit we have two electronic components, the
Connection: active and the passive buzzers. They make look same but their
behavior is different. Active buzzers makes beep sounds on their
own. It means that as soon as a voltage source is given, it starts to
beep. The passive buzzer is more like a speaker that makes variable
sounds depending on the tone programmed to it.
Lesson 3: Introduction to Buzzers(Code Discussion) Page 17 of 44

Here we have defined active and passive buzzer pins and


configured both of them as outputs.
int passive_buzzer =9;
int active_buzzer =12;
void setup()
{ pinMode(passive_buzzer,OUTPUT);
pinMode(active_buzzer,OUTPUT); }

And we use digitalWrite command to turn on and off active buzzer.


digitalWrite(active_buzzer,HIGH);
delay(200); digitalWrite(active_buzzer,LOW);
delay(200);

digitalWrite(active_buzzer,HIGH);
delay(200);
digitalWrite(active_buzzer,LOW);
Then we have used two for loops to give pwm signal to passive buzzer
from 0 to 255 for (int i = 0; i < 256; i++) {
analogWrite(passive_buzzer,i);
delay(10); }
and from 255 to 0.
for (int i = 255; i > 0; i--) {
analogWrite(passive_buzzer,i);
delay(10); }
Lesson 4: Knight Rider Page 18 of 44

Connection:

Description:
In this lesson, we are going to make a light set
like in the Knight Rider car.

Components:
•Arduino Uno board
•Solderless breadboard
•10 pcs LED
•10 pcs resistor
•Jumperwires
Lesson 4: Knight Rider (Code Discussion) Page 19 of 44

Here we have not given any names to the pins we just used the pin
numbers. In the setup we have used a for loop to configure the pins as
output instead of configure them one by one
for (int i = 2; i < 12; i++)
{ pinMode(i,OUTPUT); }
Then in the loop there are two for loops. First one is to light leds one after
one from pin 2 to pin 11
for (int i= 2; i < 12; i++)
{ digitalWrite(i,HIGH);
delay(delay_time);
digitalWrite(i,LOW); }
Other one is to light leds one after one from pin 11 to pin 2
for (int i= 11; i > 1; i--)
{ digitalWrite(i,HIGH);
delay(delay_time);
digitalWrite(i,LOW); }

So process of the code is:


First for loop(in the setup) – configure pins 2 to 11 as outputs.
Note that for loop’s i variable also used as the pin number
Second for loop (in the loop) – give 5V output to each pin one after one
from pin 2 to 11
Third for loop (in the loop) – give 5V output to each pin one after one from
pin 11 to 2
Lesson 5: LED Fade Page 20 of 44

Description:
In this lesson, we are going to change the
brightness of an LED.

Components:
•Arduino Uno board
•Solderless breadboard Circuit Explanation:
•LED
•Resistor A LED is connected with a current limiting resistor to
•Jumperwires arduino digital pin 9. It works as a PWM pin (analog output).
What is PWM?
Connection: PWM stands as pulse width modulation. This is a way to
output analog voltage out by using logic high and low.
Lesson 5: LED Fade(Code Discussion) Page 21 of 44

Pin numbering and setup functions are same as the blink


experiment. In the loop we can see a for loop which counts 0 to 255
and 255 to 0. The only thing you haven’t seen before is
analogWrite(led_pin,i); command this is the line that enables PWM
out. Let’s identify the command line.

Obviously analogWrite is the command identifier then in the


brackets we can see 2 things separated by a comma.

•led_pin – this is the pin number (same as digitalWrite command)we


want enable PWM out, this should be pwm enabled pin in the board
otherwise it just gives a digital out
•i – this is the integer value decide the output voltage. Range of this
value should be 0-255, 0 is 0V 255 is 5V, each number in between
represents various voltage levels

(Note that how i is varied from 0-255 by the for loop) delay is to keep
the led for each voltage for some time
Lesson 6: LED Fade with Potentiometer Page 22 of 44

Description:
In this lesson, we are going to change the
brightness of an LED using a potentiometer.

Components:
•Arduino Uno board
•Solderless breadboard Circuit Explanation:
•LED
•Potentiometer A LED is connected with a current limiting resistor to
•Jumperwires arduino digital pin 9. The middle pin of the potentiometer is
connected to the A0 pin of arduino.
Connection:
Most potentiometers have 3 pins. Middle pin has a variable
resistance relative to the other 2 pins.
Lesson 6: LED Fade with Potentiometer(Code Discussion) Page 23 of 44

In the setup function you can see we have configure pin 9 as a


output as usual and A0 pin is configured as a input (Note that how
INPUT is all upper case)

In the loop you can see 4 code lines you are familiar with two of
them (analogWrite & delay) lets get to know about other two lines.

val = analogRead(pot_pin); - what this line does is read the voltage


level from the potentiometer and store it in the variable called val.
Arduino gives analog voltage input values as a number in rage of 0 –
1023.

mapped_val = map(val,0,1023,0,255); - this is used to get the analog


input value (in the range of 0-1023) to the analog output range (0-255)
and store it in the variable called mapped_val

Let’s see the structure of the map function. Arduino map function
returns (output) a integer value that’s why we can use the “=” sign
directly. In the brackets you can see there are 5 values separated by
commas lets identify what are those.
•val – the input value. We can use a variable or a number directly for
this
•1 st 0 – the starting value of the input value’s range
•1023 – the end value of the input value’s range
•2 nd 0 – the starting value of the output value’s range
•255 – the end value of the output value’s range
Lesson 7: Light Sensing Circuit Page 24 of 44

Description:
In this lesson, we are going to fade an LED
according to the ambient light.

Components:
•Arduino Uno board
•Solderless breadboard
•LED Circuit Explanation:
•LDR
•Resistor Voltage Divider Circuit
•Jumperwires Voltage divider circuit is a simple circuit with two
resistors which is used to divide a voltage into two or more
Connection: parts according to a given ratio.

LDR is connected to a simple voltage divider with a 1k resistor.


Variable voltage pin of the divider if connected to the A0 and
the Led is connected to pin 9 as usual with a current limiting
resistor.
Lesson 7: Light Sensing Circuit (Code Discussion) Page 25 of 44

The code is same as the led fade we read analog value


from A0 and mapped that value and the output PWM signal is
set to that mapped value.
Lesson 8: Seven Segment Page 26 of 44

Description:
In this lesson, we are going to show numbers in a
seven segment display.

Components:
•Arduino Uno board
•Solderless breadboard
•Resistor
•Jumperwires Structure of a Seven Segment:
•Seven Segment Display
Seven segments consist of 7 (8 for ones with decimal
Connection: points) individual LEDS. Each pin is connected together to
form one common pin. The type of the display is decided by
this common pin as either common anode or common
cathode.
Lesson 8: Seven Segment(Code Discussion) Page 27 of 44
Lesson 8: Seven Segment(Code Discussion) Page 28 of 44
Lesson 8: Seven Segment(Code Discussion) Page 29 of 44

Arduino digital pin 2 – 9 are named as the segment names


(a to g & dp). All these pins are configured as outputs. That’s all
for the setup. In the loop we have switched the segments on off
according to the truth table by keeping 2 seconds delay
between each number. To count 0 to 9 we have used a for loop
with a one second delay .
Lesson 9: 4 Digit Seven Segment Display Page 30 of 44

Description: Structure of a 4-Digit Seven Segment Display and Pin


In this lesson, we are going to show numbers in a Connections:
4 digit seven segment display.

Components:
•Arduino Uno board
•Solderless breadboard
•Resistors
•Jumperwires
•4 digit Seven Segment Display
The following are the pin connections for this sample
Connection: tutorial:

LCD Display Pin Arduino Uno Pin


12 + resistor between 2
9 + resistor between 3
8 + resistor between 4
6 + resistor between 5
11 6
7 7
4 8
2 9
1 10
10 11
5 12
3 13
Lesson 9: 4 Digit Seven Segment Display(Code Discussion) Page 31of 44
Lesson 9: 4 Digit Seven Segment Display(Code Discussion) Page 32of 44

Please refer to the .ino file included with this tutorial for
the full code. Explanations are added as comments to fully
understand the functions.
Lesson 10: Tilt-Activated LED Page 33of 44

Description:
In this lesson, we are going to turn the arduino’s
built-in LED on using the status of the ball switch sensor.

Components:
•Arduino Uno board
•Solderless breadboard
•Resistor What is a Ball Switch Sensor?
•Jumperwires
•Ball Switch Sensor Tilt sensors allow you to detect orientation or
inclination. They are small, inexpensive, low-power and
Connection: easy-to-use. They are usually made by a cavity of some
sort (cylindrical is popular) and a conductive free mass
inside, such as a blob of mercury or rolling balls. One end
has two conductive elements (poles). When the sensor is
oriented so that the end is downwards, the mass rolls
onto the poles and shorts them, acting as switch throw.

While not as precise or flexible as full


acceleremoter, tilt switches can detect motion or
orientation.
Lesson 10: Tilt-Activated LED (Code Discussion) Page 34 of 44

Please refer to the .ino file included with this tutorial for
the full code. Explanations are added as comments to fully
understand the functions.
Lesson 11: IR Remote Control Page 35 of 44

Description:
In this lesson, we are going to use the IR sensor
and remote control.

Components:
•Arduino Uno board
•Jumperwires
•IR sensor What is an IR Receiver Sensor?
•Remote Control
IR receivers/detectors are little microchips with a
Connection: photocell that are tuned to listen to infrared light. They
are almost always used for remote control detection.
Inside the remote is a matching IR led, which emits IR
pulses. IR light is not visible to the human eye, which
means it takes a little more work to test a setup.
Lesson 11: IR Remote Control(Code Discussion) Page 36 of 44

Please refer to the .ino file included with this tutorial for
the full code. Explanations are added as comments to fully
understand the functions.
Lesson 12: LED Dot Matrix Page 37 of 44

Description:
In this lesson, we are going to display using the Structure of a LED Matrix and pin connection
8x8 dot matrix
LED displays are often packaged as matrixes of
Components: LEDS arranged in rows of common anodes and columns
•Arduino Uno board of common cathodes, or the reverse.
•Jumperwires
•Solderless breadboard For this sample, the following is the pin connections
•Potentiometer
•8x8 LED Matrix Matrix Pin No. Arduino Pin No.
Connection: 1 13
2 12
3 11
4 10
5 16 (analog pin 2)
6 17 (analog pin 3)
7 18 (analog pin 4)
8 19 (analog pin 5)
9 2
10 3
11 4
12 5
13 6
14 7
15 8
16 9
Lesson 12: LED Dot Matrix (Code Discussion) Page 38of 44

Please refer to the .ino file included with this tutorial for
the full code. Explanations are added as comments to fully
understand the functions.
Lesson 13: Reading the Room Temperature Page 39 of 44

Description:
In this lesson, we are going to use the LM35 in
the room temperature.
Components:
•Arduino Uno board
•Jumperwires
•Solderless breadboard Structure of the LM35 Sensor
•LM35 Sensor

Connection:

The LM35 is one of the very common temperature


sensors available in the market. One side of the sensor is
rounded and the other is flat. With the flat side facing
towards you, and the pins facing down, the pins from left
to right are as illustrated in the figure above.
Lesson 13: Reading the Room Temperature(Code Discussion) Page 40 of 44

In the setup method we make a call to


the analogReference method. This allows us to set the reference
voltage of the Arduino (i.e. the value used as the top of the input
range). The reason we are using this is because the LM35 only
produces voltages from 0 to +1V, and setting the reference voltage to
INTERNAL will set it to 1.1 volts, as a result significantly improving
the precision. The second line of the setup method is simply to allow
us to read the data we are gathering via the Serial Monitor window
(found under the Tools menu).

Inside the loop method, we begin by reading the value


from the analogue input, and then divide that reading by 9.31. The
reason we divide by 9.31 is because the range of our reading is 1024
and as we have set our reference voltage to be 1.1 volts we calculate
each “step” in the analog reading as being approximately equal to
0.001074 volts, or 1.0742 millivolts. As the LM35 reports 1 degree
Celsius per 10 millivolts, this means that for every (10 / 1.0742), we
detect a one degree change i.e. every 9.31; so by dividing the
reading by 9.31 we get our temperature reading in Celsius.
The following lines of code simply write the temperature to the Serial
Monitor and then delay execution by a second (for the sake of not
spamming the Serial Monitor!).
Lesson 14: RGB Color Display Page 41 of 44

Description:
In this lesson, we are going to display the RGB What is an RGB LED Module
LED Module to display variable colors.
A full color LED module is a circuit in which an LED
Components: can be lit to any color. This is why it is called a full color LED
•Arduino Uno board module. By programming the module with a microcontroller,
•Jumperwires we can program the LED to turn to any color that we want.
•Solderless breadboard How the module works is it has 3 PWM (pulse width
•RGB LED Module modulation) pins which stand for the colors red, green, and
blue (RGB). The idea is that any color can be created with a
Connection: combination of red, green, and blue.

By blending red, green, and blue, we can showcase


all colors (full color) with the LED on the module board.
The RGB full color module is actually a very useful circuit.
Using a single LED, we can lit up any color that we want. We
can show orange, green, red, anything. It's really good if you
want a wide variety of colors and you only want to use a single
LED.

In this circuit, we will build a circuit in which all the


possible colors are showcased. We will show a blend of all the
colors which the LED can show in rapid succession with a for
loop.
Lesson 14: RGB Color Display (Code Discussion) Page 42 of 44

Please refer to the .ino file included with this tutorial for
the full code. Explanations are added as comments to fully
understand the functions.
Page 43 of 44

End of Tutorial. Thank you! 


Page 44 of 44

Anda mungkin juga menyukai