User Guides
User Guides
in Page 1 of 88
www.sunrobotics.in
support@sunrobotics.in
+91 95588 27732
Preface
Sun Robotics is a technical service team of open source software and hardware. Dedicated
to applying the Internet and the latest industrial technology in open source area, we strive
to provide best hardware support and software service for general makers and electronic
enthusiasts around the world. We aim to create infinite possibilities with sharing. No
matter what field you are in, we can lead you into the electronic world and bring your
ideas into reality.
This is an Entry Level Arduino kits. Some common electronic components and sensors are
included. Through the learning, you will get a better understanding of Arduino, and be
able to make fascinating works based on Arduino.
Contents
Getting Started with Arduino
Installing Arduino IDE and using the Uno R3 board
About Arduino Uno R3 board
Lesson- 1 Blinking LED
Lesson- 2 Three WAY TRAFFIC LIGHT Controller
Lesson- 3 Push button – LED Blinking
Lesson - 4 RGB Blinking LED (Common cathode)
Lesson - 4 RGB Blinking LED (Common Anode)
Lesson- 5 Interfacing with Keypad Module
Lesson- 6 Control LED Blink Rate with Potentiometer
Lesson- 7 Multiple tones with one Piezo Buzzer
Lesson- 8 Seeing the light using Photo resistor with an arduino
Lesson-9 Arduino Flame Sensor
Lesson-10 LED Matrix display 8 x 8 dots (MAX7219)
Lesson-11 Interfacing with LCD 1602 Display
Lesson-12 HC-SR04 Project
Lesson-13 Touch Sensor arduino Interface
Lesson-14 Relay Module
Lesson-15 Control Servo Motor
Lesson-16 Stepper Motor Control
Lesson-17 Soil Moisture Sensor
What is an Arduino?
Arduino is an open-source physical computing platform designed to make experimenting with
electronics more fun and intuitive. Arduino has its own unique, simplified programming language,
a vast support network, and thousands of potential uses, making it the perfect platform for both
beginner and advanced DIY enthusiasts.
www.arduino.cc
Access the Internet: In order to get your Arduino up and running, you'll need to download some
software first from www.arduino.cc (it's free!). This software, known as the Arduino IDE, will
allow you to program the Arduino to do exactly what you want. It’s like a word processor for
writing programs. With an internet-capable computer, open up your favorite browser and type
in the following URL into the address bar:
www.arduino.cc/en/Main/Software
Use the USB cable provided in the kit to connect the Arduino to one of your computer’s USB
inputs.
Windows Installation Process: Go to the web address below to access the instructions for
installations on a Windows-based computer.
http://arduino.cc/en/Guide/Windows
Macintosh OS X Installation Process: Macs do not require you to install drivers. Enter the
following URL if you have questions. Otherwise proceed to next page.
http://arduino.cc/en/Guide/MacOSX
Linux: 32 bit / 64 bit, Installation Process Go to the web address below to access the instructions
for installations on a Linux-based computer.
http://www.arduino.cc/playground/Learning/Linux
Windows: 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.
Mac OS: Select the serial device of the Arduino board from the Tools > Serial Port menu. On the
Mac, this should be something with /dev/tty.usbmodem (for the Uno or Mega 2560) or
/dev/tty.usbserial (for older boards) in it.
NOTE: Do NOT use a power supply greater than 20 Volts as you will overpower (and thereby
destroy) your Arduino. The recommended voltage for most Arduino models is between 6 and 12
Volts. Pins (5V, 3.3V, GND, Analog, Digital, PWM, AREF)
Reset Button
Just like the original Nintendo, the Arduino has a reset button (10). Pushing it will temporarily
connect the reset pin to ground and restart any code that is loaded on the Arduino. This can be
very useful if your code doesn’t repeat, but you want to test it multiple times. Unlike the original
Nintendo however, blowing on the Arduino doesn’t usually fix any problems.
TX RX LEDs
TX is short for transmit, RX is short for receive. These markings appear quite a bit in electronics
to indicate the pins responsible for serial communication. In our case, there are two places on
the Arduino UNO where TX and RX appear – once by digital pins 0 and 1, and a second time next
to the TX and RX indicator LEDs (12). These LEDs will give us some nice visual indications
whenever our Arduino is receiving or transmitting data (like when we’re loading a new program
onto the board).
Voltage Regulator
The voltage regulator (14) is not actually something you can (or should) interact with on the
Arduino. But it is potentially useful to know that it is there and what it’s for. The voltage regulator
does exactly what it says – it controls the amount of voltage that is let into the Arduino board.
Think of it as a kind of gatekeeper; it will turn away an extra voltage that might harm the circuit.
Of course, it has its limits, so don’t hook up your Arduino to anything greater than 20 volts.
Overview:
In this practical, we will start the journey of learning Arduino UNO .To begin, let's learn how
to make an LED blink.
Components:
1 x Arduino UNO
1 x USB Cable
1 x 220Ω Resistor
1 x LED
1 x BreadBoard
2 x Jumper Wires
Principle:
In this lesson, we will program the Arduino's GPIO output high level (+5V) and low level (0V), and
then make the LED which is connected to the Arduino’s GPIO flicker with a certain frequency.
The LED is the abbreviation of light emitting diode. It is usually made of gallium arsenide, gallium
phosphide semiconductor materials. The LED has two electrodes: a positive electrode and a
negative one. It lights up only when a forward current passes, and it can flash red, blue, green,
yellow, etc. The color of the light depends on the material it is made.
In general, the drive current for LED is 5-20mA. Therefore, in reality it usually needs an extra
resistor for current limitation so as to protect the LED.
2. What is resistor?
Schematic:
3. Key functions:
●setup()
The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start
using libraries, etc. The setup function will only run once, after each powerup or reset of the
Arduino board.
●loop()
After creating a setup() function, which initializes and sets the initial values, the loop()function
does precisely what its name suggests, and loops consecutively, allowing your program to change
and respond. Use it to actively control the Arduino board.
●pinMode()
Configures the specified pin to behave either as an input or an output.
As of Arduino 1.0.1, it is possible to enable the internal pullup resistors with the mode
INPUT_PULLUP. Additionally, the INPUT mode explicitly disables the internal pullups.
●digitalWrite()
Write a HIGH or a LOW value to a digital pin. If the pin has been configured as an OUTPUT with
pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for
HIGH, 0V (ground) for LOW.
Step 2: Program: You can copy paste the below program in the IDE or open the code directly.
From the “CODE” folder that comes with the DVD/from the downloaded Zip folder.
/***********************************************************
File name: 01_blinkingLed.ino Description:
Let, LED blinks. ***************************************************/
int ledPin = 13;// LED connected to digital pin 13
void setup() {
pinMode(ledPin,OUTPUT);
}
void loop()
{
digitalWrite(ledPin,HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(ledPin,LOW); // set the LED off
delay(1000); // wait for a second
}
Step 3: Compile the program and upload to Arduino UNO board. Now you can see the LED
blinking.
Components:
1 x Arduino UNO
1 x USB Cable
3 x 200Ω Resistor
3 x 5mm RED LED
3 x 5mm YELLOW LED
3 x 5mm GREEN LED
1 x Breadboard
Several jumper wires
Principle:
The principle of this experiment is very simple and is quite similar with that in the second lesson.
This Arduino based 3-Way Traffic Light Controller is a simple project which is useful to understand
the working of traffic lights which we see around us. We have covered a simpler version of traffic
lights in this traffic light circuit. Here have demonstrated it for 3 sides or ways. Now let’s get into
the project.
The code for this Arduino Traffic Light Controller Project is simple and can be easily understood.
Here we have demonstrated Traffic lights for the 3 ways road and the code glows LED’s on all the
three sides in a particular sequence, in which the actual Traffic Lights works. Like, at a time, there
will be two Red signals on any of the two sides and one Green light on the remaining side. And
yellow light will also glow, for 1 second each time, in between transition from Red to Green,
means first red light glows for 5 second then yellow light glows for 1 second and then finally green
light will be turned on.
Schematic:
void loop()
{
digitalWrite(2,1); //enables the 1st set of signals
digitalWrite(7,1);
digitalWrite(10,1);
digitalWrite(4,0);
digitalWrite(3,0);
digitalWrite(6,0);
digitalWrite(8,0);
digitalWrite(9,0);
digitalWrite(5,0);
delay(4000);
Components:
1 x Arduino UNO
1 x USB Cable
1 x 220Ω Resistor
1 x 10KΩ Resistor
1 x LED
1 x Push Button
1 x Breadboard
Several jumper wires
Principle
1. Button
Buttons are a common component used to control electronic devices. They are usually used as
switches to connect or disconnect circuits. Although buttons come in a variety of sizes and
shapes, the one used in this experiment will be a 12mm button as shown below.
The button we used is a normally open type one. The two contacts of a button are in the off state
under the normal conditions; only when the button is pressed they are closed.
The button jitter must happen in the process of using. The jitter waveform is as the flowing
picture:
2. Interrupt
Hardware interrupts were introduced as a way to reduce wasting the processor's valuable time
in polling loops, waiting for external events. They may be implemented in hardware as a distinct
system with control lines, or they may be integrated into the memory subsystem .
. Key functions:
●attachInterrupt(interrupt, ISR, mode)
Specifies a named Interrupt Service Routine (ISR) to call when an interrupt occurs.
Replaces any previous function that was attached to the interrupt. Most Arduino boards have
two
external interrupts: numbers 0 (on digital pin 2) and 1 (on digital pin 3).
Generally, an ISR should be as short and fast as possible. If your sketch uses multiple ISRs, only
one can run at a time, other interrupts will be ignored (turned off) until the current one is
finished. as delay() and millis() both rely on interrupts, they will not work while an ISR is running.
delayMicroseconds(), which does not rely on interrupts, will work as expected.
Syntax:
attachInterrupt(pin, ISR, mode)
Parameters: pin: the pin number
ISR: the ISR will be called when the interrupt occurs; this function must take no parameters and
return nothing. This function is sometimes referred to as an interrupt service routine.
Reads the value from a specified digital pin, either HIGH or LOW. Syntax:
digitalRead(pin)
Parameters:
pin: the number of the digital pin you want to read (int) Returns:
HIGH or LOW ●delayMicroseconds(us)
Pauses the program for the amount of time (in microseconds) specified as parameter. There are
a thousand microseconds in a millisecond, and a million microseconds in a second.
Currently, the largest value that will produce an accurate delay is 16383. This could change in
future Arduino releases. For delays longer than a few thousand microseconds, you should use
delay() instead.
Syntax:
delayMicroseconds(us)
Parameters:
us: the number of microseconds to pause (unsigned int) Returns:
None
Schematic :
Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
What we use in this experiment is a common anode RGB LED. The longest pin is the
common anode of the three LEDs. The pin is connected to the +5V pin of the Arduino,
and the rest pins are connected to pin D8, D9, and D10 of the Arduino with a current
limiting resistor between.
In this way, we can control the color of an RGB LED by 3-channel PWM signals.
Common cathode
Procedure:
Step 1: Build the circuit
void setup() {
pinMode (8,OUTPUT);
pinMode (9,OUTPUT);
pinMode (10,OUTPUT);
}
Void loop() {
digitalWrite (8,HIGH);
digitalWrite (10,LOW);
delay(1000);
digitalWrite (9,HIGH);
digitalWrite (8,LOW);
delay(1000);
digitalWrite (10,HIGH);
digitalWrite (9,LOW);
delay(1000);
}
What we use in this experiment is a common anode RGB LED. The longest pin is the
common anode of the three LEDs. The pin is connected to the +5V pin of the Arduino,
and the rest pins are connected to pin D8, D9, and D10 of the Arduino with a current
limiting resistor between.
In this way, we can control the color of an RGB LED by 3-channel PWM signals.
Common Anode
Procedure:
Step 1: Build the circuit
void setup() {
pinMode (8,OUTPUT);
pinMode (9,OUTPUT);
pinMode (10,OUTPUT);
}
Void loop() {
digitalWrite (8,HIGH);
digitalWrite (10,LOW);
delay(1000);
digitalWrite (9,HIGH);
digitalWrite (8,LOW);
delay(1000);
digitalWrite (10,HIGH);
digitalWrite (9,LOW);
delay(1000);
}
Components:
1 x Arduino Uno
1 x USB cable
1 x Membrane switch module
1 x Breadboard
Jumper wires
Principle
Keypads are used in all types of devices, including cell phones, fax machines, microwaves, ovens,
door locks, etc. They're practically everywhere. Tons of electronic devices use them for user
input.
So knowing how to connect a keypad to a microcontroller such as an UNO R3 board is very
valuable for building many different types of commercial products.
At the end when all is connected properly and programmed, when a key is pressed, it show up at
the Serial Monitor on your computer. Whenever you press a key, it shows up on the Serial
Monitor. Later, in another project, we will connect the keypad circuit, so that it will get displayed
on an LCD. But for now, for simplicity purposes, we start at simply showing the key pressed on
the computer.
For this project, the type of keypad we will use is a matrix keypad. This is a keypad that follows
an encoding scheme that allows it to have much less output pins than there are keys. For
example, the matrix keypad we are using has 16 keys (0-9, A-D, *, #), yet only 8 output pins. With
a linear keypad, there would have to be 17 output pins (one for each key and a ground pin) in
order to work. The matrix encoding scheme allows for less output pins and thus much less
connections that have to make for the keypad to work. In this way, they are more efficient than
linear keypads, being that they have less wiring.
Schematic:
Step 2: Program
/***********************************************************
Components
1 x Arduino UNO
1 x USB Cable
1 x Breadboard
1 x 5mm RED LED
1 x 220Ω Resistor
1 x 10kΩ Potentiometer
Jumper wires
Principle
Connect one pin from your pot to 5V, the center pin to analog pin A2 and the remaining pin to
ground. Next, connect a 220 ohm current limiting resistor to digital pin 13, with an LED in series.
The long, positive leg (the anode) of the LED should be connected to the output from the resistor,
with the shorter, negative leg (the cathode) connected to ground.
Schematic
Procedure:
Step 2: Program
/***********************************************************
File name: 06 Control LED Blink Rate With Potentiometer. Ino Description:
Let, LED Using potentiometer. ************************************/
int potPin = A0; // select the input pin for the potentiometer
int ledPin = 9; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
}
void loop() {
val = analogRead(potPin); // read the value from the sensor
digitalWrite(ledPin, HIGH); // turn the ledPin on
delay(val); // stop the program for some time
digitalWrite(ledPin, LOW); // turn the ledPin off
delay(val); // stop the program for some time
}
Step 3: Compile the program and upload to Arduino UNO board.
Overview:
In this lesson, you will learn how to use a buzzer.
COMPONENTS
1 x Arduino UNO
1 x USB Cable
1 x Buzzer
1 x BreadBoard
2 x Jumper Wires
Principles
The working principle of buzzer it to use PWM generating audio to make the air to vibrate.
Appropriately changed as long as the vibration frequency, it can generate different sounds. For
example, sending a pulse of 523Hz, it can generate Alto Do, pulse of 587Hz, it can generate
midrange Re, pulse of 659Hz, it can produce midrange Mi. By the buzzer, you can play a song.
We should be careful not to use the UNO R3 board analog Write () function to generate a pulse
to the buzzer, because the pulse output of analog Write () is fixed (500Hz).
Schematic
Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 7 Buzzer Arduino Circuit .ino Description:
Let, buzzer Multiple tones. ******************************************/
void loop() {
tone(buzzer,1000);
delay(1000);
noTone(buzzer);
delay(1000);
}
Step 3: Compile the program and upload to Arduino UNO board.
Overview:
In this lesson, we will learn how to measure the light intensity by photo resistor.
Components
1 x Arduino UNO
1 x USB cable
1 x 10kΩ Resistor
1 x 220Ω Resistor
1 x LED
1 x Photo Resistor
1 x BreadBoard
Jumper wires
Principle:
A photo resistor is a light-controlled variable resistor. The resistance of a photo resistor decreases
with the increasing incident light intensity; in other words, it exhibits photoconductivity. A photo
resistor can be applied in light-sensitive detector circuits.
A photo resistor is made of a high resistance semiconductor. In the dark, a photoresistor can have
a resistance as high as a few megohms (MΩ), while in the light, a photo resistor can have a
resistance as low as a few hundred ohms. If incident light on a photo resistor exceeds a certain
frequency, photons absorbed by the semiconductor give bound electrons enough energy to jump
into the conduction band. The resulting free electrons (and their whole partners) conduct
electricity, thereby lowering resistance. The resistance range and sensitivity of a photo resistor
can substantially differ among dissimilar devices. Moreover, unique photo resistors may react
substantially differently to photons within certain wavelength bands.
Schematic:
Step 2: Program
Overview:
In this project we have to study about the project is a simple Arduino flame sensor.
Components:
1 x Arduino UNO
1 x USB Cable
1 x Flame Sensor
1 x Breadboard
Jumper wire
Principle:
The digital and analog interfaces on the KY-026, use a lighter or a candle to interact with the
flame detector module.
The digital interface will send a HIGH signal when fire is detected by the sensor, turning on the
LED on the Arduino (pin A0). Turn the potentiometer clock-wise to increase the detection
threshold and counter-clockwise to decrease it.
Schematic:
Procedure:
Step 2: Program
/***********************************************************
File name: 9 Arduino Flame Sensor.ino Description:
Let, fire is detected by the sensor turning on the LED ***************************/
const int sensorMin = 0; // sensor minimum
const int sensorMax = 1024; // sensor maximum
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorReading = analogRead(A0);
int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
switch (range) {
case 0: // A fire closer than 1.5 feet away.
Serial.println("** Close Fire **");
break;
case 1: // A fire between 1-3 feet away.
Serial.println("** Distant Fire **");
break;
case 2: // No fire detected.
Serial.println("No Fire");
break;
}
delay(1); // delay between reads
}
Step 3: Compile the program and upload to Arduino UNO board.
Overview:
In this project, we will learn about LED Matrix Displays 8×8 dots (MAX7219) Interface with
Arduino.
Components:
1 x Arduino UNO
1 x USB Cable
1 x Dot Matrix(MAX7219)
1 x Breadboard
Jumper wires
Principle:
The MAX7219/MAX7221 are compact, serial input/output common-cathode display drivers that
interface to microcontrollers and microprocessors to control 7-segment numeric LED displays of
up to 8 digits, bar-graph displays, or 64 individual LEDs. Included on the MAX7219 chip is a BCD
code-B decoder, a multiplex scan circuitry, a segment and digit drivers, and an 8×8 static RAM
that stores each digit. Only one external resistor is required to set the segment current for all
LEDs. The MAX7221 is compatible with SPI, QSPI, and MICROWIRE communication protocols, and
has slew-rate-limited segment drivers to reduce EMI. Individual digits of the connected LED
display may be addressed and updated without rewriting the entire display. The
MAX7219/MAX7221 also allow the user to select code-B decoding or no-decode for each digit.
Schematic:
Procedure:
Step 2: Program
/***********************************************************
File name: 10- LED Matrix display 8 x 8 dots (MAX7219).ino Description:
Let, LED Matrix Displays 8×8 dots (MAX7219) Interface with Arduino .****************************/
#include <LedControl.h>
int DIN = 12;
int CS = 11;
int CLK = 10;
byte e[8]= {0x7C,0x7C,0x60,0x7C,0x7C,0x60,0x7C,0x7C};
byte d[8]= {0x78,0x7C,0x66,0x66,0x66,0x66,0x7C,0x78};
byte u[8]= {0x66,0x66,0x66,0x66,0x66,0x66,0x7E,0x7E};
byte c[8]= {0x7E,0x7E,0x60,0x60,0x60,0x60,0x7E,0x7E};
byte eight[8]= {0x7E,0x7E,0x66,0x7E,0x7E,0x66,0x7E,0x7E};
byte s[8]= {0x7E,0x7C,0x60,0x7C,0x3E,0x06,0x3E,0x7E};
byte dot[8]= {0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18};
byte o[8]= {0x7E,0x7E,0x66,0x66,0x66,0x66,0x7E,0x7E};
byte m[8]= {0xE7,0xFF,0xFF,0xDB,0xDB,0xDB,0xC3,0xC3};
LedControl lc=LedControl(DIN,CLK,CS,0);
void setup() {
lc.shutdown(0,false); //The MAX72XX is in power-saving mode on startup
lc.setIntensity(0,15); // Set the brightness to maximum value
lc.clearDisplay(0); // and clear the display
}
Principle
LCD1602 is a kind of character LCD display. The LCD has a parallel interface, meaning that the
microcontroller has to manipulate several interface pins at once to control the display. The
interface consists of the following pins:
● A register select (RS) pin that controls where in the LCD's memory you're writing data to. You
can select either the data register, which holds what goes on the screen, or an instruction
register, which is where the LCD's controller looks for instructions on what to do next.
● A Read/Write (R/W) pin that selects reading mode or writing mode
● An Enable pin that enables writing to the registers
● 8 data pins (D0-D7). The state of these pins (high or low) is the bits that you're writing to a
register when you write, or the values when you read.
● There are also a display contrast pin (Vo), power supply pins (+5V and Gnd) and LED Backlight
(Bklt+ and BKlt-) pins that you can use to power the LCD, control the display contrast, and turn
on or off the LED backlight respectively.
The process of controlling the display involves putting the data that form the image of what you
want to display into the data registers, then putting instructions in the instruction register. The
Liquid Crystal Library simplifies this for you so you don't need to know the low-level instructions.
The Hitachi-compatible LCDs can be controlled in two modes: 4-bit or 8-bit. The 4-bit mode
requires seven I/O pins from the Arduino, while the 8-bit mode requires 11 pins. For displaying
text on the screen, you can do most everything in 4-bit mode.
Procedure:
Step 1: Build the circuit
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
}
Step 3: Compile the program and upload to Arduino UNO board.
Component:
1 x Arduino UNO
1 x USB Cable
1 x Ultrasonic sensor
1 x Breadboard
Jumper wire
Principle:
The HC-SR04 uses sound instead of light as the GP2D12 module does. The HC-SR04 sends a ping
as a submarine does and measure the time between sending and receiving anything back when
an object is in front of the sensor. Because using sound for its measurements we can reach up to
4 meters. The module is about 45x20x15 mm in size and has a 4 pin connection. Two pins are
needed to power the module with 5 Volts. The working current is about 15 mA. One pin is the
trigger ping and the last one is used to read the result of the measurements, the echo pin. The
measuring angle from the HC-SR04 is 15 degree. At 4 meter distance this should be a beam of
about 1 meter. At 1 meter this is 26 cm so we have to keep this in mind when using this
information.
Schematic:
Procedure:
Step 2: Program
/***********************************************************
File name: 12 – HC-SR04 Project .ino Description:
Let, Distance measure with ultrasonic sensor.************************/
#include <HCSR04.h>
const int TriggerPin = 8; //Trig pin
const int EchoPin = 9; //Echo pin
long Duration = 0;
void setup() {
pinMode(TriggerPin,OUTPUT); // Trigger is an output pin
pinMode(EchoPin,INPUT); // Echo is an input pin
Serial.begin(9600); // Serial Output
}
void loop() {
digitalWrite(TriggerPin, LOW);
delayMicroseconds(2);
digitalWrite(TriggerPin, HIGH); // Trigger pin to HIGH
delayMicroseconds(10); // 10us high
digitalWrite(TriggerPin, LOW); // Trigger pin to HIGH
Overview:
In this project I made a touch sensor using a coin that works based on Arduino.
Components:
1 x Arduino UNO
1 x USB Cable
1 x Touch Sensor
1 x BreadBoard
Jumper Wires
Principle
This device uses your body as part of the circuit. When you touch the sensor pad, the capacitance of the
circuit is changed and is detected. That detected change in capacitance results in the output changing
states.
When I first got this, I expected a glitch device that while functional, would occasionally have
unpredictable output results.
I may have been wrong. After playing for a few hours, I can’t seem to get it to do anything other than
what I expected it to do. If you’re looking for robust user input, this might do the trick.
Schematic:
Procedure:
Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 13 Touch Sensor arduino Interface .ino Description:
Let, Touch sensor using. ****************************/
#define sensorPin 2 // capactitive touch sensor - Arduino Digital pin D2
int ledPin = 13; // Output display LED (on board LED) - Arduino Digital pin D13
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(sensorPin, INPUT);
}
void loop() {
int senseValue = digitalRead(sensorPin);
if (senseValue == HIGH){
digitalWrite(ledPin, HIGH);
Serial.println("TOUCHED");
}
else{
digitalWrite(ledPin,LOW);
Serial.println("not touched");
}
delay(500);
}
Step 3: Compile the program and upload to Arduino UNO board.
Overview:
In this lesson, you will learn how to use a relay module.
Components
1 x Arduino UNO
1 x USB Cable
1 x BreadBoard
1 x Relay Module
Jumper wire
Principle
A relay is an electrically operated switch. Many relays use an electromagnet to
mechanically operate a switch, but other operating principles are also used as in solid
state relays. Relays are used where it is necessary to control a circuit by a low-power
signal (with complete electrical isolation between control and controlled circuits), or
where several circuits must be controlled by one signal. The first relays were used in
long-distance telegraph circuits as amplifiers. They repeated the signal coming in from
one circuit and retransmitted it on another circuit. Relays were used extensively in
telephone exchanges and early computers to perform logical operations.
A type of relay that can handle the high power required to directly control an electric
motor or other loads is called a contactor. Solid-state relays control power circuits with
no moving parts, instead using a semiconductor device to perform the switching.
Relays with calibrated operating characteristics and sometimes multiple operating
coils are used to protect electrical circuits from overload or faults. In modern electric
power systems, these functions are performed by digital instruments called
"protective relays".
Schematic
Step 2: Program
int relayPin = 3;
void setup() {
pinMode(relayPin, OUTPUT);
}
void loop() {
digitalWrite(relayPin, LOW); // turn the relay on (Active LOW operation)
delay(2000); // wait for a second
digitalWrite(relayPin, HIGH); // turn the relay off by making the voltage HIGH
delay(2000); // wait for a second
}
Step 3: Compile the program and upload to Arduino UNO board.
Overview:
Servo is a type of geared motor that can only rotate 180 degrees. It is controlled by sending
electrical pulses from your UNO R3 board. These pulses tell the servo what position it should
move to. A servo has three wires, the brown wire is GND, the red one is VCC, and the orange one
is signal line.
COMPONENTS:
1 x Arduino UNO
1 x USB Cable
1 x Servo Motor
1 x BreadBoard
2 x Jumper Wires
Schematic:
Procedure:
Step 1: Build the circuit
/***********************************************************
File name: 15 Control Servo Motor .ino Description:
Let, servo motor rotate **********************************************************/
# include <Servo.h>
Servo myservo;
int pos = 0;
void setup() {
myservo.attach(6);
}
void loop() {
for (pos = 0; pos <= 180; pos += 5) {
myservo.write(pos);
delay(15);
}
for (pos = 180; pos >= 0; pos -= 5) {
myservo.write(pos);
delay(15);
}
}
Step 3: Compile the program and upload to Arduino UNO board.
Overview:
In this lesson, we will learn how to control a stepper motor.
Components:
1 x Arduino UNO
1 x USB Cable
1 x Stepper Motor
1 x Motor Driver Module
1 x Battery
Jumper wires
Principle
Most stepper motors will operate only with the help of a driver module. This is because the
controller module (In our case Arduino) will not be able to provide enough current from its I/O
pins for the motor to operate. So we will use an external module like ULN2003 module
as stepper motor driver. There are a many types of driver module and the rating of one will
change based on the type of motor used.
The circuit Diagram for the arduino stepper motor control project is shown above. We have used
the 28BYJ-48 Stepper motor and the ULN2003 Driver module. To energize the four coils of the
stepper motor we are using the digital pins 8,9,10 and 11. The driver module is powered by the
5V pin of the Arduino Board.
But, power the driver with External Power supply when you are connecting some load to the
steppe motor. Since I am just using the motor for demonstration purpose I have used the +5V
rail of the Arduino Board. Also remember to connect the Ground of the Arduino with the ground
of the Diver module.
Procedure:
Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 16 stepper Motor Control .ino Description:
Let, Control stepper motor. *********************************************/
#include <Stepper.h>
#define STEPS 64
Stepper stepper(STEPS, 8, 9, 10, 11);
int previous = 0;
void setup() {
stepper.setSpeed(30);
}
void loop() {
int val = analogRead(0);
stepper.step(val - previous);
previous = val;
}
Step 3: Compile the program and upload to Arduino UNO board.
Overview:
In this project we will study about Soil Moisture sensor are specifically designed to detect the
amount of moisture or water soil contains using with Arduino.
Components:
1 x Arduino UNO
1 x USB Cable
1 x Soil Moisture Sensor
Jumper Wires
Principle
Soil Moisture sensor are specifically designed to detect the amount of moisture or water soil
contains. It uses capacitance to measure the dielectric constant of the soil. Dielectric constant
can be called as the ability of soil to transmit electricity. The soil increases as the water content
of the soil increases. Dielectric constant of water is more than any other soil component that is
why soil sensor uses that factor for moisture detection. The sensor creates a voltage proportional
to the dielectric permittivity, and therefore detects the water content of the soil.
Schematic:
Procedure:
Step 1: Build the circuit
void setup() {
Serial.begin(9600);
}
void loop() {
value = analogRead(hygrometer); // Read analog value
value = constrain(value,400,1023); // Keep the ranges!
value = map(value,400,1023,100,0); // Map value : 400 will be 100 and 1023 will be 0
Serial.print("Soil humidity: ");
Serial.print(value);
Serial.println("%");
delay(1000); // Read every 1 sec
}
Step 3: Compile the program and upload to Arduino UNO board.
Components:
1 x Arduino UNO
1 x USB Cable
1 x Vibration Sensor Module
1 x LED
1 x BreadBoard
Jumper Wires
Principle
Vibrations can be an indicator that trouble is coming. It can be your machine going haywire, a
gear on a robot missing a teeth, or worse, a looming earthquake! In this vibration sensor tutorial,
we will look at how to detect vibrations using especially designed sensors and an Arduino
microcontroller. There are two widely available vibration sensors in the market: SW-420
and 801S.
Schematic:
Procedure:
Step 1: Build the circuit
int vib_pin=7;
int led_pin=13;
void setup() {
pinMode(vib_pin,INPUT);
pinMode(led_pin,OUTPUT);
}
void loop() {
int val;
val=digitalRead(vib_pin);
if(val==1)
{
digitalWrite(led_pin,HIGH);
delay(1000);
digitalWrite(led_pin,LOW);
delay(1000);
}
else
digitalWrite(led_pin,LOW);
}
Step 3: Compile the program and upload to Arduino UNO board.
Schematic:
Arduino GND --> Module pin GND
Arduino +5V --> Module PLUS (middle pin)
Arduino Digital pin 11 --> Module S
Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
Step 3: Compile the program and upload to Arduino UNO board.
Components:
1 x Arduino Uno
1 x USB Cable
1 x Sound sensor module
1 x Breadboard
Jumper wires
Principle:
The Sound Sensor has two output: AO, analog output, real-time output voltage signal of
microphone DO, when the intensity of the sound to reach a certain threshold, the output high
and low level signal, the threshold - sensitivity can be achieved by potentiometer adjustment
period.
Schematic:
KY-037 Arduino
A0 -
+ 5v
G GND
D0 Pin 2
Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
Components:
1 x Arduino Uno
1 x USB cable
1 x Joystick Module
1 x Breadboard
Jumper wires
Principle
Joystick
The module has 5 pins: Vcc, Ground, X, Y, Key. Note that the labels on yours may be slightly
different, depending on where you got the module from. The thumb stick is analog and should
provide more accurate readings than simple „directional‟ joysticks tact use some forms of
buttons, or mechanical switches. Additionally, you can press the joystick down (rather hard on
mine) to activate a „press to select‟ push-button.
We have to use analog Arduino pins to read the data from the X/Y pins, and a digital pin to read
the button. The Key pin is connected to ground, when the joystick is pressed down, and is floating
otherwise. To get stable readings from the Key /Select pin, it needs to be connected to Vcc via a
pull-up resistor. The built in resistors on the Arduino digital pins can be used. For a tutorial on
how to activate the pull-up resistors for Arduino pins, configured as inputs.
Schematic
Procedure:
Step 2: Program
/***********************************************************
File name: 21 - Analog Joystick Module.ino Description:
Let ,Analog Joystick Module***********************************************/
const int SW_pin = 2; // digital pin connected to switch output
const int X_pin = A0; // analog pin connected to X output
const int Y_pin = A1; // analog pin connected to Y output
void setup() {
pinMode(SW_pin, INPUT);
digitalWrite(SW_pin, HIGH);
Serial.begin(9600);
}
void loop() {
Serial.print("Switch: ");
Serial.print(digitalRead(SW_pin));
Serial.print("\n");
Serial.print("X-axis: ");
Serial.print(analogRead(X_pin));
Serial.print("\n");
Serial.print("Y-axis: ");
Serial.println(analogRead(Y_pin));
Serial.print("\n\n");
delay(500);
}
Step 3: Compile the program and upload to Arduino UNO board.
COMPONENTS
1 x Arduino UNO
1 x USB Cable
1 x DTH11 Temperature Sensor
1 x BreadBoard
Jumper Wires
Schematic:
Procedure:
Step 1: Build the circuit
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("=================================");
Serial.println("Sample DHT11...");
byte temperature = 0;
byte humidity = 0;
byte data[40] = {0};
if (dht11.read(pinDHT11, &temperature, &humidity, data)) {
Serial.print("Read DHT11 failed");
return;
}
Serial.print("Sample RAW Bits: ");
for (int i = 0; i < 40; i++) {
Serial.print((int)data[i]);
if (i > 0 && ((i + 1) % 4) == 0) {
Serial.print(' ');
}
Components:
1 x Arduino UNO
1 x USB Cable
1 x 4 Digit 7-segment Display
1 x Breadboard
Several jumper wires
Principle
When using 1-digit 7-segment display and it is common anode, the common anode pin connects
to the power source; if it is common cathode, the common cathode pin connects to the GND.
When using 4-digit 7-segment display, the common anode or common cathode pin is used to
control which digit is displayed. Even though there is only one digit working, the principle of
Persistence of Vision enables you to see all numbers displayed because each the scanning speed
is so fast you hardly notice the intervals.
Schematic
#include <TM1637Display.h>
const int CLK = 9; //Set the CLK pin connection to the display
const int DIO = 8; //Set the DIO pin connection to the display
int NumStep = 0; //Variable to interate
TM1637Display display(CLK, DIO); //set up the 4-Digit Display.
void setup() {
display.setBrightness(0x0a); //set the diplay to maximum brightness
}
void loop() {
for(NumStep = 0; NumStep < 9999; NumStep++) //Interrate NumStep
{
display.showNumberDec(NumStep); //Display the Variable value;
delay(500); //A half second delay between steps.
}
}
Step 3: Compile the program and upload to Arduino UNO board.
Overview:
In this lesson, we will learn how to use the tilt sensor module is equipped with a tilt sensor and
a potentiometer
Components
1 x Arduino UNO
1 x USB Cable
1 x Tilt Switch Module
1 x Breadboard
Several jumper wires
Principle
Tilt sensors are essential components in security alarm systems today. Standalone tilt sensors
sense tilt angle or movement. Tilt sensors can be implemented using mercury and roller ball
technology, and can be mounted using mechanical threading, magnets, or adhesives,
depending on what type of surface they are being mounted to.
Schematic
Procedure:
Step 1: Build the circuit
Overview:
In this tutorial, you will learn to how to apply the RC522 RFID Reader Module on UNO R3.This
module uses the Serial Peripheral Interface (SPI) bus to communicate with controllers such as
Arduino, Raspberry Pi, beagle board, etc.
Components:
1 x Arduino Uno
1 x USB cable
1 x Rc522 module
1 x Breadboard
Jumper wires
Principle:
The MFRC522 is a highly integrated reader/writer for contactless communication at 13.56
MHz .The MFRC522 reader supports ISO 14443A / MIFARE® mode.
The MFRC522‟s internal transmitter part is able to drive a reader/writer antenna designed
to communicate with ISO/IEC 14443A/MIFARE® cards and transponders without additional
active circuitry. The receiver part provides a robust and efficient implementation of a
demodulation and decoding circuitry for signals from ISO/IEC 14443A/MIFARE® compatible
cards and transponders. The digital part handles the complete ISO/IEC 14443A framing and
error detection (Parity & CRC).The MFRC522 supports MIFARE®Classic (e.g. MIFARE®
Standard) products. The MFRC522 supports contactless communication using MIFARE®
higher transfer speeds up to 848 Kbit/s in both directions.
Schematic:
Step 2: Program
/*************************************************
File name: 25- Interfacing RC522 RFID Module with Arduino.ino Description:
Let, RFID module. **********************************/
#include <SPI.h>
Components:
1 x Arduino Uno
1 x USB Cable
1 x Bluetooth Module HC-05
1 x Breadboard
Jumper wires
Principle:
Arduino can communicate with other devices via Bluetooth using the module HC-05
(master/slave). It enables the Arduino to connect and exchange data with other devices such as
Smartphone, computer or other microcontrollers. Bluetooth communication can be used to
control a robot remotely, Display and store data on your computer or on your smartphone, for
instance.
Schematic:
Key – Arduino Pin 9
Vcc – Arduino 5v
GND – Arduino GND
TXD – Arduino Pin 10
RXD – Arduino Pin 11
Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
void setup() {
// put your setup code here, to run once:
Genotronex.begin(9600);
Genotronex.println("Bluetooth On please press 1 or 0 blink LED ..");
pinMode(ledpin,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if (Genotronex.available()){
BluetoothData=Genotronex.read();
if(BluetoothData=='1'){ // if number 1 pressed ....
digitalWrite(ledpin,1);
Genotronex.println("LED On D13 ON ! ");
}
if (BluetoothData=='0'){// if number 0 pressed ....
digitalWrite(ledpin,0);
Genotronex.println("LED On D13 Off ! ");
}
}
delay(100);// prepare for next data ...
}
Step 3: Compile the program and upload to Arduino UNO board.
AT Commands
Slave Configuration
To set the module as a slave, you can change the name as AT+NAME=HC05-Slave and choose the
communication parameters and the PIN code that you want. You’ll need to make sure that
master and slave as the same communication parameters.
AT returns OK
AT+NAME=HC05-Slave
AT+UART=9600,0,0
AT+ROLE=0
Enter AT+ADDR to obtain the module address (ex: +ADDR:98d3:32:21450e)
Master Configuration
To set the module as master, you need to change the role and set the same communication
parameter as the slave module.
AT returns OK
AT+NAME=HC05-Master
AT+UART=9600,0,0
AT+ROLE=1
The slave module address must be enter in the master module to allows it to appair:
AT+BIND=98d3,32,21450e (replace dots “:” by coma “,”)
Overview:
In this tutorial we have to study about the Thermistor Sensor Module is used to sense
temperature and convert it into output signals.
Components:
1 x Arduino Uno
1 x USB Cable
1 x Thermal sensor
1 x Breadboard
Jumper wires
Principle:
Thermistor Sensor Module is used to sense temperature and convert it into output signals. It is
associated with both analog output pin and digital output pin labelled as AO and DO respectively
on the board. Thermistor Sensor Module is made of semiconductor materials. Basically
thermistor sensors are mostly Negative Temperature Coefficient (NTC), which means NTC
thermistors will have their electrical resistance decreased when subjected to an increase in body
temperature. This module has a potentiometer knob that can be adjusted to change the
sensitivity of thermistor towards temperature.
Schematic:
Thermistor Arduino
A0 A5
D0 -
G GND
+ 5v
Procedure:
Step 1: Build the circuit
void setup(){
Serial.begin(9600);
}
void loop() {
unsigned int AnalogValue;
AnalogValue = analogRead(A5);
Serial.println(AnalogValue);
delay(1000);
}
Step 3: Compile the program and upload to Arduino UNO board.
Overview:
In this tutorial we have study about DC Motor control forward direction or revere direction using
RGB LED.
COMPONENTS
1 x Arduino UNO
1 X USB Cable
1 x BreadBoard
1 x RGB LED
1 x Push Button
1 x Dc Motor
1 x 10kΩ Resistor
Jumper wires
Principle:
Control the rotation of the DC Motor either clockwise or counter clockwise thru the switch and
make the RGB LED as indicator e.g. Blue for clockwise and Red for counter clockwise.
Schematic:
Step 2: Program
/***********************************************************
File name: 28 DC Motor Direction Control.ino Description:
Let, DC motor control by RGB LED. ****************************************/
const int inputPin=1;
const int blue=3;
const int red=4;
const int motorPin1=5, motorPin2=6;
int dir = LOW;
int prevState=0, currentState=0;
void setup() {
pinMode(inputPin, INPUT);
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(red, OUTPUT);
}
void loop () {
currentState=digitalRead(inputPin);
if (currentState!= prevState)
{
if (currentState == HIGH)
{
dir = !dir;