Arduino uno kit Manual
TABLE OF CONTENT
Contents pages
The Kit Contents .................................................................................................................................................... 4
Introduction ............................................................................................................................................................ 5
How to use it ............................................................................................................................................. 5
What you will need ................................................................................................................................... 5
What exactly is an Arduino? ............................................................................................................................. 7
Getting Started ....................................................................................................................................................... 9
Download the Arduino IDE ....................................................................................................................... 9
Connect the board .................................................................................................................................... 9
Install the USB Drivers............................................................................................................................... 9
Upload your first Sketch.......................................................................................................................... 10
Project 1 - LED TURN ON ................................................................................................................................ 13
What you will need ................................................................................................................................. 13
Connect it up ........................................................................................................................................... 13
Project 2 – BLINK LED...................................................................................................................................... 14
CODE FOR BLINKING LED ........................................................................................................................ 14
Project 3 – TURN ON TWO LEDs .................................................................................................................. 15
CODE FOR TURNING ON TWO LEDs ........................................................................................................ 15
Project 3 – BLINK TWO LEDs ........................................................................................................................ 16
CODE FOR BLINKING TWO LEDs.............................................................................................................. 16
Project 4 – DIGITAL READ (PUSH BUTTON) ........................................................................................... 17
CODE FOR DIGITAL READ (PUSH BUTTON) ............................................................................................. 17
Project 5 – PUSH BUTTON TO CONTROL LED ........................................................................................ 18
CODE FOR PUSH BUTTON TO CONTROL LED .......................................................................................... 18
Project 6 – READ ANALOG INPUT ............................................................................................................... 19
CODE FOR READING ANALOG INPUT ...................................................................................................... 19
Project 7 –READ ANALOG VOLTAGE .......................................................................................................... 20
CODE FOR READING ANALOG VOLTAGE ................................................................................................. 20
Project 8 – ANALOG INPUT CONTROLLING LED ................................................................................... 21
CODE FOR ANALOG INPUT CONTROLLING LED ...................................................................................... 21
Project 9 – SIMPLE TONE GENERATION .................................................................................................. 22
CODE FOR SIMPLE TONE GENERATION .................................................................................................. 22
Project 10 – ALTERNATING PITCHES ........................................................................................................ 23
CODE FOR ALTERNATING PITCHES.......................................................................................................... 23
Project 11 – GENERATING A SOUND WITH A BUTTON ..................................................................... 24
CODE FOR GENERATING A SOUND WITH A BUTTON ............................................................................. 24
Project 12 – GENERATING A SOUND WITH A BUTTON ..................................................................... 25
CODE FOR SOUNDS DEPENDING ON DIFFERENT KEYS ........................................................................... 25
Project 13 – GENERATING multipletone .................................................................................................. 27
CODE FOR GENERATING MULTIPLE TONE .............................................................................................. 27
THE KIT CONTENTS
Arduino UNO LED (Light Emitting
Resistors USB cable
Board Diod)
IR receiver 7-Segment Display
Push button IR remote
4x4 Matrix Keypad Breadboard DC Motor
Buzzer
Photo Resistor Potentiometer 74hc595 LM35
Distance Sensor Servomotor
Relay Motion Sensor
IR Sensor Capacitor
Stepper Motor Wire Jumpers
INTRODUCTION
The purpose of this book and the kit is to give you a gentle introduction to the Arduino,
electronics and programming in C and to set you up with the necessary skills needed to
progress beyond the book and the kit into the world of the Arduino and microcontroller
electronics.
The booklet has been written presuming that you have no prior knowledge of electronics,
the Arduino hardware, software environment or of computer programming. At no time will
we get too deep into electronics or programming in C. There are many other resources
available for free that will enable you to learn a lot more about this subject if you wish to go
further. The best possible way to learn the Arduino, after using this kit of course, is to join
the Arduino Forum on the Arduino website and to check out the code and hardware
examples in the ‘Playground’ section of the Arduino website too.
We hope you enjoy using the kit and get satisfaction from creating the projects and seeing
your creations come to life.
How to use it
The book starts off with an introduction to the Arduino, how to set up the hardware, install
the software, etc.
We then explain the Arduino IDE and how to use it before we dive right into some projects
progressing from very basic stuff through to advanced topics. Each project will start off
with a description of how to set up the hardware and what code is needed to get it working.
We will then describe separately the code and the hardware and explain in some detail
how it works.
Everything will be explained in clear and easy to follow steps. The book contains a lot of
diagrams and photographs to make it as easy as possible to check that you are following
along with the project correctly.
What you will need
Firstly, you will need access to the internet to be able to download the Arduino IDE
(Integrated Development Environment) and to also download the Code Samples within this
book (if you don’t want to type them out yourself) and also any code libraries that may be
necessary to get your project working.
You will need a well-lit table or other flat surface to lay out your components and this will
need to be next to your desktop or laptop PC to enable you to upload the code to the
Arduino. Remember that you are working with electricity (although low voltage DC) and
therefore a metal table or surface will first need to be covered in a non-conductive material
(e.g. tablecloth, paper, etc.) before laying out your materials.
Finally, the most important thing you will need is enthusiasm and a willingness to learn.
The Arduino is designed as a simple and cheap way to get involved in microcontroller
electronics and nothing is too hard to learn if you are willing to at least ‘give it a go’. This
Arduino Kit will help you on that journey and introduce you to this exciting and creative
hobby.
WHAT EXACTLY IS AN ARDUINO?
an Arduino is a tiny computer that you can program to process inputs and outputs going to
and from the chip.
The Arduino is what is known as a Physical or Embedded Computing platform, which
means that it is an interactive system, that through the use of hardware and software can
interact with it’s environment.
For example, a simple use of the Arduino would be to turn a light on for a set period of time,
let’s say 30 seconds, after a button has been pressed (we will build this very same project
later in the book). In this example, the Arduino would have a lamp connected to it as well as
a button. The Arduino would sit patiently waiting for the button to be pressed. When you
press the button, it would then turn the lamp on and start counting. Once it had counted 30
seconds it would then turn the lamp off and then carry on sitting there waiting for another
button press. You could use this set-up to control a lamp in an under-stair’s cupboard for
example. You could extend this example to sense when the cupboard door was opened and
automatically turn the light on, turning it off after a set period of time.
The Arduino can be used to develop stand-alone interactive objects, or it can be connected
to a computer to retrieve or send data to the Arduino and then act on that data (e.g. Send
sensor data out to the internet).
The Arduino can be connected to LED displays, LED’s. Dot Matrix displays, buttons,
switches, motors, temperature sensors, pressure sensors, distance sensors, SD card,
webcams, printers, GPS receivers, ethernet modules, and so on.
The Arduino board is made of an an Atmel AVR Microprocessor, a crystal or oscillator
(basically a crude clock that sends time pulses to the microcontroller to enable it to operate
at the correct speed) and a 5-volt linear regulator. Depending on what type of Arduino you
have, you may also have a USB connector to enable it to be connected to a PC or Mac to
upload or retrieve data. The board exposes the microcontroller’s I/O (Input/Output) pins
to enable you to connect those pins to other circuits or to sensors, etc.
To program the Arduino (make it do what you want it to) you also use the Arduino IDE
(Integrated Development Environment), which is a piece of free software, that enables you
to program in the language that the Arduino understands. In the case of the Arduino the
language is C. The IDE enables you to write a computer program, which is a set of step-
bystep instructions that you then upload to the Arduino. Then your Arduino will carry out
those instructions and interact with the world outside. In the Arduino world, programs are
known as ‘Sketches ‘.
The Arduino hardware and software are both Open Source, which means the code, the
schematics, design, etc. are all open for anyone to take freely and do what they like with it.
This means there is nothing stopping anyone from taking the schematics and PCB designs
of the Arduino and making their own and selling them.
GETTING STARTED
Get an Arduino UNO board and USB cable
Firstly, get your Arduino board and lay it on the table in front of you. Take the USB cable
and plug the B plug (the fatter squarer end) into the USB socket on the Arduino UNO board
.
At this stage do NOT connect the Arduino UNO board to your PC or Mac yet.
Download the Arduino IDE
Get the latest version from the download page.
When the download finishes, unzip the downloaded file. Make sure to preserve the folder
structure. Double-click the folder to open it. There should be a few files and sub-folders
inside.
If you double-click the folder, you will see a few files and sub-folders inside.
Connect the board
The Arduino Uno, Mega, Duemilanove and Arduino Nano automatically draw power from
either the USB connection to the computer or an external power supply. If you're using an
Arduino Diecimila, you'll need to make sure that the board is configured to draw power
from the USB connection. The power source is selected with a jumper, a small piece of
plastic that fits onto two of the three pins between the USB and power jacks. Check that it's
on the two pins closest to the USB port.
Connect the Arduino board to your computer using the USB cable. The green power LED
(labelled PWR) should go on.
Install the USB Drivers
The Installing drivers for the UNO.
Installing drivers for the Arduino UNO, Nano, or Diecimila with Windows7, 10.
When you connect the board, Windows should initiate the driver installation process (if
you haven't used the computer with an Arduino board before).
You can check that the drivers have been installed by opening the Windows Device
Manager (in the Hardware tab of System control panel). Look for a "USB Serial Port" in the
Ports section; that's the Arduino board.
Upload your first Sketch
Now that your Arduino UNO board has been connected and the drivers for the USB chip
have been installed, we are now ready to try out the Arduino for the first time and upload
your first Sketch.
Navigate to your newly unzipped Arduino folder and look for the Arduino IDE icon, which
looks something like this....
Double click the ICON to open the IDE. You will then be presented with a
blue and white screen with a default sketch loaded inside.
This is the Arduino IDE (Integrated Development Environment) and is
where you will write your Sketches (programs) to upload to your Arduino
board.
1) Open the LED blink example sketch: File > New
2) And then you should select your board.
3) Select your serial port
Select the serial device of the Arduino board from the Tools | Serial Port menu.
This is likely to be COM3 or higher (COM1 and COM2 are usually reserved for
hardware serial ports). To find out, you can disconnect your Arduino board and
re-open the menu; the entry that disappears should be the Arduino board.
Reconnect the board and select that serial port.
4) Upload the program
Now, simply click the "Upload" button in the environment. Wait a few seconds -
you should see the RX and TX leds on the board flashing. If the upload is
successful, the message "Done uploading." will appear in the status bar.
PROJECT 1 - LED TURN ON
In this project we are going to write the following program to turn on LED and testing the
Arduino, that is to TURN ON an LED. However, this time we are going to use one of the
LED’s in the kit and you will also learn about some electronics and coding in C along the
way.
What you will need
• Breadboard Red LED
• 220 Ω Resistor
• Jumper Wires
Connect it up
Now, first make sure that your Arduino is powered off. You can do this either by
unplugging the USB cable or by taking out the Power Selector Jumper on the Arduino
board. Then connect everything up like this:
int ledPin = 13;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH);
}
PROJECT 2 – BLINK LED
CODE FOR BLINKING LED
int ledPin = 13;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}
PROJECT 3 – TURN ON TWO LEDS
CODE FOR TURNING ON TWO LEDs
int ledPin1 = 13;
int ledPin2 = 12;
void setup() {
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
void loop() {
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
}
PROJECT 3 – BLINK TWO LEDS
CODE FOR BLINKING TWO LEDs
int ledPin1 = 13;
int ledPin2 = 12;
void setup() {
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
void loop() {
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
delay(1000);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
delay(1000);
}
PROJECT 4 – DIGITAL READ (PUSH BUTTON)
CODE FOR DIGITAL READ (PUSH BUTTON)
int pushButton = 7;
void setup() {
[Link](9600);
pinMode(pushButton, INPUT);
}
void loop() {
int buttonState = digitalRead(pushButton);
[Link](buttonState);
delay(10);
}
PROJECT 5 – PUSH BUTTON TO CONTROL LED
CODE FOR PUSH BUTTON TO CONTROL LED
int buttonPin = 7;
int ledPin = 4;
int buttonState = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}
PROJECT 6 – READ ANALOG INPUT
CODE FOR READING ANALOG INPUT
void setup() {
[Link](9600);
}
void loop() {
int sensorValue = analogRead(A0);
[Link](sensorValue);
delay(10);
}
PROJECT 7 –READ ANALOG VOLTAGE
CODE FOR READING ANALOG VOLTAGE
void setup() {
[Link](9600);
}
void loop() {
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.0);
[Link](voltage);
}
PROJECT 8 – ANALOG INPUT CONTROLLING LED
CODE FOR ANALOG INPUT CONTROLLING LED
int sensorPin = A0;
int ledPin = 13;
int sensorValue = 0;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
sensorValue = analogRead(sensorPin);
if (sensorValue==500)
{
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
}}
PROJECT 9 – SIMPLE TONE GENERATION
CODE FOR SIMPLE TONE GENERATION
void setup()
{
//No information needed in the setup
//the output gets automatically defined with the “tone” command
}
void loop()
{
tone(8, 100); // The"tone ( x , y )" command creates a sound
delay(1000); // with the duration of one second
noTone(8); // The tone is deactivated
delay(1000); // for one second
}
PROJECT 10 – ALTERNATING PITCHES
CODE FOR ALTERNATING PITCHES
void setup()
{
}
void loop()
{
tone(8, 100);
delay(1000);
noTone(8); // This causes the first tone to stop
tone(8, 200); //The second tone with the pitch “200” starts
delay(1000); //for one second
noTone(8); //With this line the second tone stops and the loop starts over with
//the first tone
}
PROJECT 11 – GENERATING A SOUND WITH A BUTTON
CODE FOR GENERATING A SOUND WITH A BUTTON
int button1=6;
int buttonstatus=0;
void setup()
{
pinMode(button1, INPUT);
}
void loop()
{
buttonstatus = digitalRead(button);
if (buttonstatus == HIGH)
tone(8, 300);
else
noTone(8);
}
PROJECT 12 – GENERATING A SOUND WITH A BUTTON
CODE FOR SOUNDS DEPENDING ON DIFFERENT KEYS
int button1=6; // button1 is connected to pin6 void loop()
int button2=7; // button2 is connected to pin7
int buttonstatus1=0; //variable to save the status of button1
int buttonstatus2=0; //variable to save the status of button2
void setup()
{
pinMode(button1, INPUT); //button1 is an input
pinMode(button2, INPUT); //button2 is an input
}
void loop(
{
buttonstatus1 = digitalRead(button1); //get status from button1 (HIGH or LOW)
buttonstatus2 = digitalRead(button2); //get status from button2 (HIGH or LOW)
if (buttonstatus1 == HIGH) //If button1 gets pushed..
{
tone(8, 100); //...output of a tone with a pitch of 100...
delay (1000); //...one second long...
noTone(8); //...than turn it off
}
if (buttonstatus2 == HIGH) //If button2 gets pushed..
{
tone(8, 200); //...output of a tone with a pitch of 200...
delay (1000); //...one second long...
noTone(8); //...than turn it off
}
}
PROJECT 13 – GENERATING MULTIPLETONE
CODE FOR GENERATING MULTIPLE TONE
void setup()
{
}
void loop() {
noTone(8);
tone(6, 440, 200);
delay(200);
noTone(6);
tone(7, 494, 500);
delay(500);
noTone(7);
tone(8, 523, 300);
delay(300);
}