You are on page 1of 82

37 – in – 1 Sensor Kit for Arduino

Contents

 Getting Started with Arduino


 Installing Arduino IDE and using the Uno R3 board
 About Arduino Uno R3 board
 Lesson-1 Control led using clap system
 Lesson-2 Laser Module 650NM
 Lesson-3 Analog Joystick Module
 Lesson-4 Showing the temperature and humidity sensor in display using arduino
 Lesson-5 Arduino Flame Sensor
 Lesson-6 Relay Module
 Lesson-7 Arduino UNO-Small passive buzzer module
 Lesson-8 Arduino KY-011 2-color LED module
 Lesson-9 Arduino KY-031 Knock Sensor module
 Lesson-10 Arduino KY-002 Vibration Switch Module
 Lesson-11 Arduino KY-018 Photo resistor module
 Lesson-12 Arduino KY-004 Switch Button Module
 Lesson-13 Arduino KY-020 Tilt Switch Module
 Lesson-14 Arduino RGB full-color LED SMD module KY-009
 Lesson-15 Infrared emission sensor module KY-005
 Lesson-16 Infrared sensor Receiver module KY-022
 Lesson-17 Arduino KY-016 3-color LED module
 Lesson-18 Yin Yi 2-color LED module 3MM KY-029
 Lesson-19 Active buzzer module KY-012
 Lesson-20 Temperature sensor module KY-013
 Lesson-21 Arduino KY-021 Mini Magnetic reed modules
 Lesson-22 Arduino KY-003 Hall Magnetic sensor modules
 Lesson-23 Arduino KY-035 Class Bihor magnetic sensor
 Lesson-24 Arduino KY-027 Magic light cup module
 Lesson-25 Arduino KY-040 Rotary encoder module
 Lesson-26 Arduino KY-010 Optical broken module
 Lesson-27 Arduino KY-039 Detect the heartbeat module
 Lesson-28 Arduino KY-025 Reed module
 Lesson-29 Obstacle avoidance sensor module KY-032
 Lesson-30 Arduino Hunt Sensor module KY-033
 Lesson-31 Arduino KY-001 Temperature Sensor DS18B20 module
 Lesson-32 Arduino KY-024 Linear Magnetic Hall Sensor
 Lesson-33 Arduino KY-036 Metal touch sensor module
 Lesson-34 Arduino KY-028 Temperature sensor module
 Lesson-35Mercury open optical module KY-017
 Lesson-36 Automatic flashing colorful LED module KY-034
 Lesson-37 Sensitive microphone sensor module KY-037

Getting Started with Arduino


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

A Computer for the Physical World:


The friendly blue board in your hand (or on your desk) is the Arduino. In some ways you could
think of Arduino as the child of traditional desktop and laptop computers. At its roots, the
Arduino is essentially a small portable computer. It is capable of taking inputs (such as the push
of a button or a reading from a light sensor) and interpreting that information to control various
outputs (like a blinking LED light or an electric motor). That's where the term "physical
computing" is born - an Arduino is capable of taking the world of electronics and relating it to the
physical world in a real and tangible way. Trust us - this will all make more sense soon.

Arduino UNO SMD R3


The Arduino Uno is one of several development boards based on the ATmega328. We like it
mainly because of its extensive support network and its versatility. It has 14 digital input/output
pins (6 of which can be PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB
connection, a power jack, an ICSP header, and a reset button. Don’t worry, you’ll learn about all
these later.
Installing Arduino IDE and Using Uno R3 board

STEP-1: Download the Arduino IDE (Integrated Development Environment)

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/M,ain/Software
For different operating system platforms, the way of using Arduino IDE is different. Please refer
to the following links: Windows User:http://www.arduino.cc/en/Guide/Windows Mac OS
User:http://www.arduino.cc/en/Guide/MacOSXLinuxUserhttp://playground.arduino.cc/Learnin
g/Linux For more detailed information about Arduino IDE, please refer to the following link:
http://www.arduino.cc/en/Guide/HomePage

STEP-2: Connect your Arduino Uno to your Computer:

Use the USB cable provided in the kit to connect the Arduino to one of your computer’s USB
inputs.
STEP-3: Install Drivers
Depending on your computer’s operating system, you will need to follow specific instructions.
Please go to the URLs below for specific instructions on how to install the drivers onto your
Arduino Uno.

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
STEP-4: Open the Arduino IDE
Open the Arduino IDE software on your computer. Poke around and get to know the interface.
We aren’t going to code right away, this is just an introduction. The step is to set your IDE to
identify your Arduino Uno.
GUI (Graphical User Interface)
Verify
Checks your code for errors compiling it.
Upload
Compiles your code and uploads it to the configured board. See uploading below for
Details .Note: If you are using an external programmer with your board, you can hold
Down the "shift" key on your computer when using this icon. The text will change to
"Upload using Programmer" New Creates a new sketch.
Open
Presents a menu of all the sketches in your sketchbook. Clicking one will open it within
The current window overwriting its content. Note: due to a bug in Java, this menu
Doesn’t scroll; if you need to open a sketch late in the list, use the File | Sketch book
Menu instead.
Save
Saves your sketch.
Serial Monitor
Opens the serial monitor.
STEP-5: Select your board: Arduino Uno

STEP-6: Select your Serial Device

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.

Linux: http://playground.arduino.cc/Learning/Linux
About Arduino Uno R3 board
What's on the board?
There are many varieties of Arduino boards that can be used for different purposes. Some boards
look a bit different from the one below, but most Arduino have the majority of these components
in common:
Power (USB / Barrel Jack)
Every Arduino board needs a way to be connected to a power source. The Arduino UNO can be
powered from a USB cable coming from your computer or a wall power supply that is terminated
in a barrel jack. In the picture above the USB connection is labeled (1) and the barrel jack is
labeled (2). .

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)

The pins on your Arduino are the places where you connect wires to construct a circuit (probably
in conjunction with a breadboard and some wire. They usually have black plastic ‘headers’ that
allow you to just plug a wire right into the board. The Arduino has several different kinds of pins,
each of which is labeled on the board and used for different functions.
 GND (3): Short for ‘Ground’. There are several GND pins on the Arduino, any of which can
be used to ground your circuit.
 5V (4) & 3.3V (5): As you might guess, the 5V pin supplies 5 volts of power, and the 3.3V
pin supplies 3.3 volts of power. Most of the simple components used with the Arduino
run happily off of 5 or 3.3 volts.
 Analog (6): The area of pins under the ‘Analog In’ label (A0 through A5 on the UNO) are
Analog In pins. These pins can read the signal from an analog sensor (like a temperature
sensor) and convert it into a digital value that we can read.
 Digital (7): Across from the analog pins are the digital pins (0 through 13 on the UNO).
These pins can be used for both digital input (like telling if a button is pushed) and digital
output (like powering an LED).
 PWM (8): You may have noticed the tilde (~) next to some of the digital pins (3, 5, 6, 9,
10, and 11 on the UNO). These pins act as normal digital pins, but can also be used for
something called Pulse-Width Modulation (PWM). We have a tutorial on PWM, but for
now, think of these pins as being able to simulate analog output (like fading an LED in and
out).
 AREF (9): Stands for Analog Reference. Most of the time you can leave this pin alone. It is
sometimes used to set an external reference voltage (between 0 and 5 Volts) as the upper
limit for the analog input pins.

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.

Power LED Indicator


Just beneath and to the right of the word “UNO” on your circuit board, there’s a tiny LED next to
the word ‘ON’ (11). This LED should light up whenever you plug your Arduino into a power source.
If this light doesn’t turn on, there’s a good chance something is wrong. Time to re-check your
circuit!

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

Main IC
The black thing with all the metal legs is an IC, or Integrated Circuit (13). Think of it as the brains
of our Arduino. The main IC on the Arduino is slightly different from board type to board type,
but is usually from the AT mega line of IC’s from the ATMEL company. This can be important, as
you may need to know the IC type (along with your board type) before loading up a new program
from the Arduino software. This information can usually be found in writing on the top side of
the IC. If you want to know more about the difference between various IC’s, reading the
datasheets is often a good idea.
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.

Lesson 1 – Control LED using clap system(KY-038)


Overview:
In this tutorial we have study about that clap and make sound Led will blink using sound sensor.

Components:
 1 x Arduino Uno
 1 x USB cable
 1 x Sound Sensor
 1 x LED
 1 x 220Ω Resistor
 1 x Breadboard
 Jumper wires
Principle:
KY-038 Sound Sensor using Arduino. It also shows how you can control LED by clap with the help
of Arduino and Sound Sensor. We have shown only to control LED, but by using the same concept
you can control any electronic device.

Schematic:
KY-038 Sound Sensor having 4 Pins:
 Analog Output – AO
 G – Ground
 VCC – 5v
 Digital Output – Pin 3

Procedure:
Step 1: Build the circuit

Step 2: Program

/***********************************************************
File name: 01 - Control led using clap system. No Description:
Let, control led using clap****************************************/
int soundSensor =3;
int LED = 4 ;
boolean LEDStatus = false;
void setup() {
pinMode(soundSensor,INPUT);
pinMode(LED,OUTPUT);
}
void loop() {
int SensorData=digitalRead(soundSensor);
if(SensorData==1){
if (LEDStatus==false){
LEDStatus=true;
digitalWrite(LED,HIGH);
}
else {
LEDStatus=false;
digitalWrite(LED,LOW);
}
}
}
Step 3: Compile the program and upload to Arduino UNO board.

Lesson 2 – Laser Module 650NM (KY-008)


Overview:
In this project we have study about one of the more common devices Laser module for using
Arduino.

Components:
 1 x Arduino UNO
 1 x USB Cable
 1 x Laser Module 650NM
 1 x Breadboard
 Jumper Wires

Principle
This Keyes device is one of the more common devices found in Arduino sensor kits. Coupled
with other components, it can be used to create trip wires or optical effects.
The KY-008 is particularly neat because it can be directly powered from an Arduino output pin as
it only draws 30 mA from the processor that has outputs rated for 40 mA.

Schematic:
 Pin - = GND
 Pin (middle pin) = not connected
 Pin S = +5V
Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 2 . Laser Module 650NM .ino Description:
Let, Laser module interface with arduino. **********************/
int laserPin = 13;
void setup() { pinMode(laserPin, OUTPUT); // Define the digital output interface pin 13
}
void loop() {
digitalWrite(laserPin, HIGH); // Open the laser head
delay(1000); // Delay one second
digitalWrite(laserPin, LOW); // Close the laser head
delay(1000);
}

Step 3: Compile the program and upload to Arduino UNO board


Lesson 3 - Analog Joystick Module (KY-023)
Overview:
In this tutorial we will learn how to use the analog joystick module. Analog joysticks are a great
way to add some control in your projects.

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
 Arduino GND --> Module pin -
 Arduino +5V --> Module pin +5V
 Arduino Analog A0 --> Module VRx
 Arduino Analog A1 --> Module VRy
 Arduino Digital Pin 2--> -->Module SW

Procedure:
Step 1: Build the circuit

Step 2: Program
/***********************************************************
File name: 3 - 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.
Lesson 4 - Showing the temperature and humidity
sensor in using arduino (KY-015)

Overview:
In this tutorial we have to learn about the data from DHT11 sensor send to Arduino UNO and
then the humidity and temperature.

COMPONENTS
 1 x Arduino UNO
 1 x USB Cable
 1 x DTH11 Temperature Sensor
 1 x BreadBoard
 Jumper Wires

Schematic:
 Arduino pin 7 --> Pin S module
 Arduino GND --> Pin - module
 Arduino +5 --> Pin Middle

Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 4 Showing the temperature and humidity sensor in display using arduino.ino
Description:
Let, Showing the temperature using DHT. ****************************/
#include <SimpleDHT.h>
int pinDHT11 = 7;
SimpleDHT11 dht11;

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(' ');
}
}
Serial.println("");
Serial.print ("Sample OK: ");
Serial.print((int)temperature); Serial.print(" *C, ");
Serial.print((int)humidity); Serial.println(" %");
delay(1000);
}

Step 3: Compile the program and upload to Arduino UNO board.

Lesson 5 - Arduino Flame Sensor (KY-026)

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:

 Arduino GND --> Module G


 Arduino +5V --> Module +
 Arduino digital 4 --> Module D0
 Arduino A0 --> Module A0

Procedure:
Step 1: Build the circuit

Step 2: Program
/***********************************************************
File name: 5 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
Lesson 6 - Relay Module (KY-019)
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

 Arduino digital pin 6 --> module pin S


 Arduino GND --> module pin -
 Arduino +5V --> module pin +
Procedure:
Step 1: Build the circuit

Step 2: Program
/***********************************************************
File name: 6 Relay Module. ino Description:
Let, Relay use. *******************************************************/

int relayPin = 3;
void setup() {
pinMode(relayPin, OUTPUT);
}
void loop() {
digitalWrite(relayPin, HIGH); // turn the relay on (HIGH is the voltage level)
delay(2000); // wait for a second
digitalWrite(relayPin, LOW); // turn the relay off by making the voltage LOW
delay(2000); // wait for a second
}
Step 3: Compile the program and upload to Arduino UNO board
Lesson 7 – Arduino UNO-Small passive buzzer module
KY-006

Overview:
With Arduino you can do a lot of interactive work, the most commonly used are displays, sound
and light shows.

Components:
 1 x Arduino UNO
 1 x USB Cable
 1 x KY-006 Buzzer module
 1 x Breadboard
 Jumper Wires

Principle
Buzzer are used in electronic transducers, DC voltage power supply, wide use in computers for
error sounds, printers, copiers, alarms, electronic toys, automotive electronic equipment,
telephones, timers, etc.
The classification is divided into buzzer piezo buzzer and two types of electromagnetic buzzer.
Graphic symbols for buzzer circuit in the circuit is demoted by the letter “H” or “HA” (old standard
with “FM”, “LB”, “JD”, etc.)
Active and passive buzzer buzzer what is the difference

PassiveBuzzer:
Here the “source” does not mean power. But rather refers to the shock source (Frequency). In
other words, the active internal buzzer with shock source. The passive internal sources without
shocks, so if a DC signal can not make it tweet. Must 2K ~ 5K square wave to Drive it. Passive
buzzer are cheap as they don’t have oscillator circuit. Sound frequency control is possible.
ActiveBuzzer:
Active Buzzer comes with internal oscillator circuit. Sound frequency is fixed.

Schematic:

 Arduino digital pin 8 --> pin 'S' of module


 Arduino GND --> Pin '-' of module
Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 7 – Arduino UNO-Small passive buzzer module
Let, a lot of interactive work, the most commonly used are displays, sound and light
shows.********************/
int buzzer = 8 ;// buzzer signal connected to this pin
void setup () {
pinMode (buzzer, OUTPUT) ;// set the digital IO pin mode, OUTPUT out of Wen
}
void loop () {
unsigned char i, j ;// define variables
while (1) {
for (i = 0; i <80; i++) // Wen a frequency sound
{
digitalWrite (buzzer, HIGH) ;// send voice
delay (1) ;// Delay 1ms
digitalWrite (buzzer, LOW) ;// do not send voice
delay (1) ;// delay ms
}
for (i = 0; i <100; i++) // Another frequency sound
{
digitalWrite (buzzer, HIGH) ;// send voice
delay (2) ;// delay 2ms
digitalWrite (buzzer, LOW) ;// do not send voice
delay (2) ;// delay 2ms
}
}
}
Step 3: Compile the program and upload to Arduino UNO board
Lesson 8 – Arduino KY-011 2-color LED module

Overview:
In this tutorial we have to study about 3mm Two color LED module KY-011 for Arduino, emits red
and green light. It uses bi-color led. You can adjust the amount of each color using PWM.
Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-011 LED module
 2 x 220Ω Resistor
 1 x Breadboard
 Jumper wires
Principle:
The Two-color LED is a handy little component that allows three colors (red, green and
combination) in a single LED having three pins (cathode and red, green). The color of the LED
depends on the input given to the red or green pin. Similar LED’s that provide two or even three
colors usually have three or four pins allowing for a wide range of mixed colors. This LED can
easily be applied to a circuit to visually indicate polarity direction or OK, fault conditions.

This module consist of a common cathode 3mm red/green LED and a 0Ω resistor, since operating
voltage is 2.0v ~2.5v you’ll need to use limiting resistors to prevent burnout when connecting to
the Arduino.

Schematic:

 Arduino pin 10 --> resistor 220 Ohm --> Signal pin of the module
 Arduino pin 11 --> resistor 220 Ohm --> Middel pin of the module
 Arduino GND --> module -/GND

Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 8 – Arduino KY-011 2-color LED module
Let, You can adjust the amount of each color using PWM. ********************/
int redpin = 11; // select the pin for the red LED
int greenpin = 10; // select the pin for the green LED
int val;
void setup () {
pinMode (redpin, OUTPUT);
pinMode (greenpin, OUTPUT);
}
void loop () {
for (val = 255; val > 0; val--)
{
analogWrite (greenpin, val);
analogWrite (redpin, 255-val);
delay (15);
}
for (val = 0; val < 255; val++)
{
analogWrite (greenpin, val);
analogWrite (redpin, 255-val);
delay (15);
}
}
Step 3: Compile the program and upload to Arduino UNO board
Lesson 9 - Arduino KY-031 Knock Sensor module
Overview:
In this tutorial we have to study about 13 knock sensor module and a digital interface, built-in LED
build a simple circuit to produce percussion flasher.
Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-031 Knock sensor module
 1 x Breadboard
 Jumper wires
Principle:
The knock sensor, detects the knocks and the taps. It can work like a switch. The sensor sends
data momentarily to the board. To keep the LED on, the button state change codes should be
used. So the sensor will work as a switch.

Schematic:

 Arduino GND --> module -/GND


 Arduino 5v--> module -/ 5v
 Arduino pin 3 --> Signal pin of the module

Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 9 -Arduino KY-031 Knock Sensor module
Let, KY-031 Knock Sensor module.********************/
int Led = 13 ; // define LED Interface
int Shock = 3; // define the percussion Sensor Interface
int val ; // define numeric variables val

void setup () {
pinMode (Led, OUTPUT) ; // define LED as output interface
pinMode (Shock, INPUT) ; // define knock sensor output interface
}
void loop () {
val = digitalRead (Shock) ; // read digital interface is assigned a value of 3 val
if (val == HIGH) // When the percussion when the sensor detects a signal, LED flashes
{
digitalWrite (Led, LOW);
}
else {
digitalWrite (Led, HIGH);
}
}
Step 3: Compile the program and upload to Arduino UNO board

Lesson 10 – Arduino KY-002 Vibration Switch Module


Overview:
In this tutorial we have to study about the Keyes 002 Vibration Sensor allows you to use an Arduino
to detect impacts, shocks or shaking. When the switch detects a jolt, the output of the module is
sent low.
Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-002 Vibration Switch Module
 1 x LED
 1 x Breadboard
 Jumper wires
Principle:
The switch primarily consists of a terminal that forms a center post and a second terminal that
is a spring that surrounds the center post. When a sufficient force is transferred to the switch,
the terminal consisting of the spring moves and shorts both terminals together.
The connection between the terminals is momentary and will require a little thought as you
implement it in your Arduino project. Positioning of the switch is also important. Generally
speaking the switch should be physically located as close as possible to the area being
monitored. Otherwise, the vibration being detected may be dampened by other structural
components in you project.
An exception to this rule may be where you find that the switch is too sensitive for your
application. In this case, moving the switch further away from the area of interest may make it
less sensitive.

Schematic:
 Pin(-) = GND, connect to GND of the Arduino
 Pin (middle pin) +5 v, connect to Arduino +5
 Pin(S) signal, connect to Arduino pin 3
When there is vibration the Arduino LED on pin 13 flashes.

Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 10 – Arduino KY-002 Vibration Switch Module
Let, When the switch detects a jolt, the output of the module is sent low. ********************/
int Led = 13 ;// define LED Interface
int Shock = 2; // define the vibration sensor interface
int val; // define numeric variables val
void setup () {
pinMode (Led, OUTPUT) ; // define LED as output interface
pinMode (Shock, INPUT) ; // output interface defines vibration sensor
}
void loop () {
val = digitalRead (Shock) ; // read digital interface is assigned a value of 3 val
if (val == LOW) // When the shock sensor detects a signal, LED flashes
{
digitalWrite (Led, HIGH); //Turn LED on
delay(1000); //Hold LED in on state for one second
}
else {
digitalWrite (Led, LOW); //Turn off LED
}
}
Step 3: Compile the program and upload to Arduino UNO board

Lesson 11 – Arduino KY-018 Photo resistor module


Overview:
Photo resistors, also known as light dependent resistors (LDR), are light sensitive devices most
often used to indicate the presence or absence of light, or to measure the light intensity. In the
dark, their resistance is very high, sometimes up to 1MΩ, but when the LDR sensor is exposed to
light, the resistance drops dramatically, even down to a few ohms, depending on the light
intensity.
Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-018 Photo resistor module
 1 x Breadboard
 Jumper wires
Principle:
Photo resistors, also known as light dependent resistors (LDR), are light sensitive devices most
often used to indicate the presence or absence of light, or to measure the light intensity. In the
dark, their resistance is very high, sometimes up to 1MΩ, but when the LDR sensor is exposed to
light, the resistance drops dramatically, even down to a few ohms, depending on the light
intensity. LDRs have a sensitivity that varies with the wavelength of the light applied and are
nonlinear devices. They are used in many applications but are sometimes made obsolete by other
devices such as photodiodes and phototransistors. Some countries have banned LDRs made of
lead or cadmium over environmental safety concerns.

Widely used in cameras, solar garden lights, lawn, detectors, clock, music, cups, gift boxes,
miniNight light, light voice switches, lights automatically switch toys and a variety of light control,
light control lighting, lamps and other light automatic opening OFF control field.

Schematic:
 Arduino A2 --> Module Signal (S)
 Arduino 5V --> Module +5V (Pin2)
 Arduino GND --> Module GND (-)

Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 11– Arduino KY-018 Photo resistor module
Let, Photo resistor module is dependent using LDR.********************/

int sensorPin = 2; //define analog pin 2


int value = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
value = analogRead(sensorPin);
Serial.println(value, DEC); // light intensity
// high values for bright environment
// low values for dark environment
delay(100);
}
Step 3: Compile the program and upload to Arduino UNO board

Lesson 12 – Arduino KY-004 Switch Button Module


Overview:
In this tutorial we, have to study about When the key is pressed the buildin LED on pin 13 will
be turned off.
Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-004 Switch Button Module
 1 x LED
 1 x Breadboard
 Jumper wires
Principle:
Arduino Key Switch Module Keyes KY-004 is a push button that will output a high signal when
pressed. The module consists of a FZ1713 tactile push button switch and a resistor. Compatible
with popular electronics platforms like Arduino, Raspberry Pi and Esp8266.
Schematic:

 Pin - = GND, connect to GND of the Arduino


 Pin (middel pin) +5 v, connect to Arduino +5
 Pin S signal, connect to Arduino pin 10

Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 12 – Arduino KY-004 Switch Button Module
Let, when we push the button, led will be on. ********************/

int Led = 13 ;// define LED Interface


int buttonpin = 3; // define the key switch sensor interface
int val ;// define numeric variables val
void setup () {
pinMode (Led, OUTPUT); // define LED as output interface
pinMode (buttonpin, INPUT); // define the key switch sensor output interface
}
void loop () {
val = digitalRead (buttonpin); // digital interface will be assigned a value of 3 to read val
if (val == HIGH) // When the key switch when the sensor detects a signal, LED flashes
{
digitalWrite (Led, HIGH);
}
else {
digitalWrite (Led, LOW);
}
}
Step 3: Compile the program and upload to Arduino UNO board.
Lesson 13 – Arduino KY-020 Tilt Switch Module
Overview:
In this tutorial we, have to study about Tilt switch module and a digital interface, built-in LED
build a simple circuit to produce tilt warning lamp comes with digital interfaces of the LED, the
tilt switch sensor interface to access digital 2, when the tilt open Off sensor senses a key signal,
LED lights, otherwise off.
Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-020 Tilt Switch Module
 1 x LED
 1 x Breadboard
 Jumper wires
Principle:
KY-020 Arduino tilt switch sensor module. Closes the circuit when it is tilted to the side as long as
it is moved with enough force and degree of inclination to activate the ball switch inside. The KY-
020 consists of a 10kΩ resistor and a metallic ball switch with bidirectional conduction that will
open/close the circuit depending on its tilt degree. It does not measure tilt angle.
Schematic:
 Pin(-) = GND, connect to GND of the Arduino
 Pin (middle pin) +5 v, connect to Arduino +5
 Pin (S) signal, connect to Arduino pin 2

Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 13 – Arduino KY-020 Tilt Switch Module
Let, tilt warning lamp come with in led build. ********************/
int Led = 13 ;// define LED Interface
int buttonpin = 2; // define the tilt switch sensor interfaces
int val ;// define numeric variables val
void setup () {
pinMode (Led, OUTPUT) ;// define LED as output interface
pinMode (buttonpin, INPUT) ;//define the output interface tilt switch sensor
}
void loop () {
val = digitalRead (buttonpin) ;// digital interface will be assigned a value of 3 to read val
if (val == HIGH) //When the tilt sensor detects a signal when the switch, LED flashes
{
digitalWrite (Led, HIGH);
}
else {
digitalWrite (Led, LOW);
}
}
Step 3: Compile the program and upload to Arduino UNO board.
Lesson 14 – Arduino RGB full- color LED SMD module
KY-009
Overview:
SMD RGB LED module consists of a full-color LED made by R, G, B three pin PWM voltage input
can be adjusted. Primary colors (red / blue / green) strength in order to achieve full color mixing
effect.
Components:
 1 x Arduino uno
 1 x USB Cable
 1 x SMD RGB LED module
 1 x 180Ω Resistor
 2 x 110 Ω Resistor
 1 x Breadboard
 Jumper wires
Principle:
SMD RGB LED module consists of a full-color LED made by R, G, B three pin PWM voltage input
can be adjusted. Primary colors (red / blue / green) strength in order to achieve full color mixing
effect. Control of the module with the Arduino can be achieved Cool lighting effects.
A LED-module which provides a red, blue and green LED. These are connected with a common
cathode. A resistor is necessary for different voltages.
Rf(3,3V)[Green]=110Ω
Rf(3,3V)[Red]=180Ω
Rf (3,3V) [Blue]=110Ω
Schematic:
 Arduino pin 9 –> 110 Ohm resistor –> Pin ‘G’ of KY-009 module
 Arduino pin 10 –> 110 Ohm resistor –> Pin ‘B’ of KY-009 module
 Arduino pin 11 –> 180 Ohm resistor –> Pin ‘R’ of KY-009 module
 Arduino GND –> pin ‘-‘ of KY-009 module

Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 14 – Arduino RGB full-color LED SMD module KY-009
Let, It shows different color of RGB light will be blinking with using resistor ********************/
int redpin = 11; // select the pin for the red LED
int bluepin = 10; // select the pin for the blue LED
int greenpin = 9; // select the pin for the green LED
int val=0;
void setup () {
pinMode (redpin, OUTPUT);
pinMode (bluepin, OUTPUT);
pinMode (greenpin, OUTPUT);
Serial.begin (9600);
}
void loop () {
for (val=255; val>0; val--) {
analogWrite (redpin, val);
analogWrite (bluepin, 255-val);
analogWrite (greenpin, 128-val);
delay (1);
}
for (val = 0; val <255; val++) {
analogWrite (redpin, val);
analogWrite (bluepin, 255-val);
analogWrite (greenpin, 128-val);
delay (1);
}
Serial.println (val, DEC);
}
Step 3: Compile the program and upload to Arduino UNO board.
Lesson 15 – Infrared emission sensor module KY-005
Overview:
In this tutorial we are using transmitter modules.
Components:
 1 x Arduino uno
 1 x USB Cable
 1 x Infrared transmitter module
 1 x Breadboard
 Jumper wires
Principle:
This is their specific physical map.
This time we want to introduce infrared transmitter and receiver modules, in fact, they are now
in our daily life. They play an important role in lots of household appliances and are used in
devices such as air conditioning, TV, DVD, etc., It is based on wireless sensing, but also can be a
remote control, very easy to use.
IR emission LEDs are used in TV remote, Lets see how to make TV remote using this module.

Schematic:

 Connect the Power line (middle) and ground (-) to +5 and GND respectively.
 Connect signal (S) to pin 3 on the Arduino UNO or pin 9 on the Arduino Mega.
 The pin number for the infrared transmitter is determined by the IRremote library.

Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 15 – Infrared emission sensor module KY-005
Let, Only transmitter modules. ********************/
#include <IRremote.h>
IRsend irsend;
void setup() {
Serial.begin(9600);
}
void loop() {
for (int i = 0; i < 50; i++) {
irsend.sendSony(0xa90, 12); // Sony TV power code
delay(40);
}
}
Step 3: Compile the program and upload to Arduino UNO board.

Lesson 16 – Infrared sensor Receiver module KY-022


Overview:
In this tutorial we are using Receiver modules KY-022.
Components:
 1 x Arduino uno
 1 x USB Cable
 1 x Infrared Receiver module
 1 x Infrared remote control
 1 x Breadboard
 Jumper wires
Principle:
This is their specific physical map.
This time we want to introduce infrared transmitter and receiver modules, in fact, they are now
in our daily life. They play an important role in lots of household appliances and are used in
devices such as air conditioning, TV, DVD, etc., It is based on wireless sensing, but also can be a
remote control, very easy to use.
IR emission LEDs are used in TV remote, Lets see how to make TV remote using this module.

Schematic:
 Arduino GND --> Module pin -
 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
/***********************************************************
File name: 16 – Infrared sensor Receiver module KY-022
Let, Only Receiver modules. ********************/

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

Lesson 17 – Arduino KY-016 3-color LED module

Overview:
In this tutorial we are using KY-016 Arduino color 5mm RGB LED different colors can be obtained
by mixing the three primary colors.
Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-016 3-color LED module
 1 x Breadboard
 Jumper wires
Principle:
KY-016 Arduino full color 5mm RGB LED, different colors can be obtained by mixing the three
primary colors. RGB LED module consists of a plug-in full color LED made by R, G, B three pin
PWM voltage input can be adjusted Section three primary colors (red / blue / green) strength in
order to achieve full color mixing effect. Control of the module with the Arduino can be achieved
Cool lighting effects.
Schematic:
 Arduino pin 11 --> Pin R module
 Arduino pin 10 --> Pin G module
 Arduino pin 9 --> Pin B module
 Arduino pin GND --> Pin - module
You don't need any resistors, these are already included on the module.

Procedure:
Step 1: Build the circuit

Step 2: Program:
Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 17 – Arduino KY-016 3-color LED module
Let, It shows different color of RGB light will be blinking ********************/

int redpin = 11; // select the pin for the red LED
int bluepin =10; // select the pin for the blue LED
int greenpin =9; // select the pin for the green LED
int val;
void setup() {
pinMode(redpin, OUTPUT);
pinMode(bluepin, OUTPUT);
pinMode(greenpin, OUTPUT);
Serial.begin(9600);
}
void loop() {
for(val = 255; val > 0; val--) {
analogWrite(11, val);
analogWrite(10, 255 - val);
analogWrite(9, 128 - val);
Serial.println(val, DEC);
delay(5);
}
for(val = 0; val < 255; val++) {
analogWrite(11, val);
analogWrite(10, 255 - val);
analogWrite(9, 128 - val);
Serial.println(val, DEC);
delay(5);
}
}
Step 3: Compile the program and upload to Arduino UNO board.

Lesson 18 – Yin Yi 2-color LED module 3MM KY-029


Overview:
In this tutorial we have to study about 3mm Two color LED module KY-029 for Arduino, emits red
and green light. It uses bi-color led. You can adjust the amount of each color using PWM.
Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-029 3MM LED module 2-color
 2 x 220Ω Resistor
 1 x Breadboard
 Jumper wires
Principle:
The Two-color LED is a handy little component that allows three colors (red, green and
combination) in a single LED having three pins (cathode and red, green). The color of the LED
depends on the input given to the red or green pin. Similar LED’s that provide two or even three
colors usually have three or four pins allowing for a wide range of mixed colors. This LED can
easily be applied to a circuit to visually indicate polarity direction or OK, fault conditions.

This module consist of a common cathode 3mm red/green LED and a 0Ω resistor, since operating
voltage is 2.0v ~2.5v you’ll need to use limiting resistors to prevent burnout when connecting to
the Arduino.

Schematic:

 Arduino pin 11 --> resistor 220 Ohm --> Signal pin of the module
 Arduino pin 12 --> resistor 220 Ohm --> Middle pin of the module
 Arduino GND --> module -/GND

Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 18 Yin Yi 2-color LED module 3MM KY-029
Let, KY-029 2 color LED module. *******/

int redpin = 12; // select the pin for the red LED
int bluepin = 11; // select the pin for the blueLED
int val;
void setup () {
pinMode (redpin, OUTPUT);
pinMode (bluepin, OUTPUT);
Serial.begin (9600);
}
void loop () {
for(val=255;val>0;val--) {
analogWrite (12, val);
analogWrite (11, 255 - val);
delay(5);
}
for(val=255;val<255;val++) {
analogWrite (12, val);
analogWrite (11, 255 - val);
delay(5);
}
}
Step 3: Compile the program and upload to Arduino UNO board.

Lesson 19 – Active buzzer module KY-012


Overview:
In this tutorial we have to study about Active Buzzer Module KY-012 Arduino module, it
produces a single-tone sound when signal is high.

Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-012 Active buzzer module
 1 x Breadboard
 Jumper wires
Principle:
This is a active buzzer so its easy in use. You just apply voltage to the buzzer and it makes sound.
Disadvantage is that you can't determine the frequency of the sounds, for this you need a passive
buzzer.

Schematic:
Module pin - = GND Module pin S = +5V
Connection to Arduino
 Arduino digital pin 8 --> Module pin S
 Arduino GND --> Module pin -
Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 19 – Active buzzer module KY-012
Let, KY-012 Active buzzer module. *******/

int speakerPin = 8;
void setup () {
pinMode (speakerPin, OUTPUT);
}
void loop () {
analogWrite (speakerPin, 255);
delay (50);
analogWrite (speakerPin, 0);
delay (10);
}
Step 3: Compile the program and upload to Arduino UNO board.
Lesson 20 – Temperature sensor module KY-013

Overview:
In this tutorial we have to study about KY-013 Temperature sensor module is based on NTC
thermistor and a 10 kΩ resistor.
Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-013 temperature sensor module
 1 x Breadboard
 Jumper wires
Principle:
Thermistors are temperature-sensing elements made of semiconductor material that has been
sintered in order to display large changes in resistance in proportion to small changes in
temperature.
This resistance can be measured by using a small and measured direct current, or dc, passed
through the thermistor in order to measure the voltage drop produced.
These solid state temperature sensors actually act like electrical resistors that are temperature
sensitive.

Schematic:

 Arduino pin analog A0 –> module S (Signal)


 Arduino pin GND – module –
 Arduino pin 5+ –> middle pin 5V

Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 20 – Temperature sensor module KY-013
Let, KY-013 Temperature sensor module. *******/

#include <math.h>

int sensorPin = A0; // select the input pin for the potentiometer
double Thermistor(int RawADC) {
double Temp;
Temp = log(10000.0*((1024.0/RawADC-1)));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15; // Convert Kelvin to Celcius
//Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
return Temp;
}
void setup() {
Serial.begin(9600);
}
void loop() {
int readVal=analogRead(sensorPin);
double temp = Thermistor(readVal);
Serial.println(temp); // display tempature
//Serial.println(readVal); // display tempature
delay(500);
}
Step 3: Compile the program and upload to Arduino UNO board.
Lesson 21 – Arduino KY-021 Mini Magnetic reed
modules

Overview:
In this tutorial we have to study about a reed switch is a magnetic sensor that is normally open and
gets closed when exposed to a magnetic field.
Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-021 mini magnetic reed module
 1 x Breadboard
 Jumper wires
Principle:
A reed module is a magnetic sensor that is normally open and get closed when exposed to a
magnetic field.
In our example turn off the buildin LED on pin 13 if the sensor is closed. For this you need to
keep a magnet near the sensor.
The module includes a 10 K Ohm resistor, so no additional parts needed.
Schematic:

 Arduino GND --> Module pin -


 Arduino +5V --> Module PLUS (middle pin)
 Arduino Digital pin 2 --> Module S

Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 21 – Arduino KY-021 Mini Magnetic reed modules
Let, Arduino KY-021 Mini Magnetic reed modules. *******/

int led = 13; // LED pin


int reelSwitch = 2; // magnetic senso rpin
int switchState; // variable to store reel switch value
void setup() {
pinMode (led, OUTPUT);
pinMode (reelSwitch, INPUT);
}
void loop() {
switchState = digitalRead(reelSwitch); // read the value of digital interface 2 and assign it to
if (switchState == HIGH) // when the magnetic sensor detect a signal, LED is flashing
{
digitalWrite(led, HIGH);
}
else {
digitalWrite(led, LOW);
}
}
Step 3: Compile the program and upload to Arduino UNO board.
Lesson 22 – Arduino KY-003 Hall Magnetic sensor
modules
Overview:
In this tutorial we have to study Hall Magnetic Sensor Module is a switch that will turn on/off in
the presence of a magnetic field.
Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-003 Hall Magnetic sensor modules
 1 x Breadboard
 Jumper wires
Principle:
The KY-003 is a magnetic switch. If no magnetic field is present, the signal line of the sensor is
HIGH (3.5 V). If a magnetic field is presented to the sensor, the signal line goes LOW, at the same
time the LED on the sensor lights up. The polarity of the magnetic field is of influence to the
switching action. The front side of the sensor needs the opposite polarity as the back of the
sensor to switch on.
In the example program the led on the Arduino (pin 13) will be turned on when a magnetic field
is present.
Schematic:

 Pin - = GND, connect to GND of the Arduino


 Pin (middle pin) +5 v, connect to Arduino +5
 Pin S signal, connect to Arduino pin 3
 Power consumption, 3 mA in rest, 8 mA when switched on
Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 22 – Arduino KY-003 Hall Magnetic sensor modules
Let, Arduino KY-003 Hall Magnetic sensor modules. *******/

int Led = 13 ; // define LED Interface


int SENSOR = 3 ; // define the Hall magnetic sensor interface
int val ; // define numeric variables val
void setup () {
pinMode (Led, OUTPUT) ; // define LED as output interface
pinMode (SENSOR, INPUT) ; // define the Hall magnetic sensor line as input
}
void loop () {
val = digitalRead (SENSOR) ; // read sensor line
if (val == LOW) // when the Hall sensor detects a magnetic field, Arduino LED lights up
{
digitalWrite (Led, HIGH);
}
{
digitalWrite (Led, LOW);
}
}
Step 3: Compile the program and upload to Arduino UNO board.
Lesson 23 – Arduino KY-035 Class Bihor magnetic sensor

Overview:
In this tutorial we have to study KY-035 is an analog magnetic field sensor module.

Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-035 Class bihor magnetic sensor
 1 x Breadboard
 Jumper wires
Principle:
KY-035 is an analog magnetic field sensor module. The strength of the field is given by an analog
voltage at the signal pin of the module KY-035. The sensor is connected to gnd and 5V of the
Arduino board. The output voltage is measured by analog pin A5 on the Arduino board.
The example program measures the output voltage of the sensor en presents the measured value
in the serial monitor of the Arduino.
The led on the board flashes in a speed depending on the strength of the magnetic field. With a
small magnet this can be demonstrated.

Schematic:
 Pin - = GND, connect to GND of the Arduino
 Pin (middle pin) +5 V, connect to Arduino +5 V
 Pin S signal, connect to Arduino pin A5
 Power consumption sensor, 8 mA

Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 23 – Arduino KY-035 Class Bihor magnetic sensor
Let, Arduino KY-035 Class Bihor magnetic sensor. *******/

int sensorPin = A5; // select the input pin


int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup () {
pinMode (ledPin, OUTPUT);
Serial.begin (9600);
}
void loop () {
sensorValue = analogRead (sensorPin);
digitalWrite (ledPin, HIGH);
delay (sensorValue);
digitalWrite (ledPin, LOW);
delay (sensorValue);
Serial.println (sensorValue, DEC);
}
Step 3: Compile the program and upload to Arduino UNO board.

Lesson 24 – Arduino KY-027 Magic light cup module


Overview:
In this tutorial we have to study Magic Light Cup Module is a set of two boards, each one has a
led and a mercury tilt switch.
Components:

 1 x Arduino uno
 1 x USB Cable
 1 x KY-027 Magic light cup module
 1 x Breadboard
 Jumper wires
Principle:
Magic Light Cup modules are easy to Interactive Technology Division developed a can and
Arduino interactive modules, PWM dimming principle is to use the principle of two modules
brightness changes. Mercury switches provide a digital signal that triggers the PWM regulator,
through the program design, we can see the light like two cups filled with the effect of shuffling
back and forth.

Schematic:

KY-027 (A) Arduino


KY-027 (B) Arduino
G GND
G GND
+ 5v
+ 5v
S 8
S 7
L 9 L 6

Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 24 – Arduino KY-027 Magic light cup module
Let, Arduino KY-027 Magic light cup module. *******/

int ledPinA = 9;
int switchPinA = 8;
int switchStateA = 0;
int ledPinB = 6;
int switchPinB = 7;
int switchStateB = 0;
int brightness = 0;
void setup() {
pinMode(ledPinA, OUTPUT);
pinMode(ledPinB, OUTPUT);
pinMode(switchPinA, INPUT);
pinMode(switchPinB, INPUT);
}
void loop() {
switchStateA = digitalRead(switchPinA);
if (switchStateA == HIGH && brightness != 255) {
brightness ++;
}
switchStateB = digitalRead(switchPinB);
if (switchStateB == HIGH && brightness != 0) {
brightness --;
}
analogWrite(ledPinA, brightness); // A slow fade out
analogWrite(ledPinB, 255 - brightness); // B slow bright up
delay(20);
}
Step 3: Compile the program and upload to Arduino UNO board.

Lesson 25 – Arduino KY-040 Rotary encoder module

Overview:
In this tutorial we have to study The Keyes KY-040 rotary encoder is a rotary input device that
provides an indication of how much the knob has been rotated AND what direction it is rotating.

Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-040 Rotary encoder module
 1 x Breadboard
 Jumper wires
Principle:
By rotating the rotary encoder can be counted in the positive direction and the reverse direction
during rotation of the output pulse frequency, unlike rotary potentiometer counter, which
Species rotation counts are not limited. With the buttons on the rotary encoder can be reset to
its initial state, that starts counting from 0.
How it works: incremental encoder is a displacement of the rotary pulse signal is converted to a
series of digital rotary sensors. These pulses are used to control Angular displacement. In Eltra
angular displacement encoder conversion using a photoelectric scanning principle. Reading
system of alternating light transmitting window and the window is not consisting of radial
indexing plate (code wheel) rotating basis, while being an infrared light source vertical irradiation
light to the code disk image onto the receiving
On the surface. Receiver is covered with a diffraction grating, which has the same code disk
window width. The receiver's job is to feel the rotation of the disc resulting changes, and change
the light into corresponding electrical changes. Then the low-level signals up to a higher level,
and generates no interference Square pulse, which must be processed by electronic circuits.
Reading systems typically employ a differential manner, about the same but the phase difference
of the two waveforms Different by 180 ° compared to the signal in order to improve the quality
and stability of the output signal. Reading is then the difference between the two signals formed
on the basis, thus eliminating the interference.

Schematic:

Rotary Encoder pin Arduino


G GND
+ 5v
DT 3
CLK 2
Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 25 – Arduino KY-040 Rotary encoder module
Let, Arduino KY-040 Rotary encoder module. *******/

enum { PinA=2, PinB=3, IPINMODE=INPUT };


static byte abOld; // Initialize state
volatile int count; // current rotary count
int old_count; // old rotary count

void setup() {
pinMode(PinA, IPINMODE);
pinMode(PinB, IPINMODE);
attachInterrupt(0, pinChangeISR, CHANGE); // Set up pin-change interrupts
attachInterrupt(1, pinChangeISR, CHANGE);
abOld = count = old_count = 0;
Serial.begin(9600);
Serial.println("Starting Rotary Encoder Test");
}
// On interrupt, read input pins, compute new state, and adjust count
void pinChangeISR() {
enum { upMask = 0x66, downMask = 0x99 };
byte abNew = (digitalRead(PinA) << 1) | digitalRead(PinB);
byte criterion = abNew^abOld;
if (criterion==1 || criterion==2) {
if (upMask & (1 << (2*abOld + abNew/2)))
count--;
else count++; // upMask = ~downMask
}
abOld = abNew; // Save new state
}
void loop() {
if (old_count != count) {
Serial.println(count);
old_count = count;
}
}
Step 3: Compile the program and upload to Arduino UNO board.

Lesson 26 – Arduino KY-010 Optical broken module

Overview:
In this tutorial we have to study Photo interupter module use the buildin arduino led. If the sensor
is broken the LED is turned on.Device senses a signal, LED lights, otherwise off.

Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-010 Optical broken module
 1 x Breadboard
 Jumper wires
Principle:
THe KY-010 Photo Interrupter module consists of an optical emitter/detector in the front and
two resistors (1 kΩ and 33 Ω) in the back. The sensor uses a beam of light between de emitter an
detector to check if the path between both is being blocked by an opaque object.

Schematic:
If you view from the top like on the photo
 Left = Ground
 Middle = +5V
 Right = Signal
Connect the module to the arduino as follows:
 Arduino pin GND to module GND
 Arduino digital pin 3 to module Signal
 Arduino pin 5V to module 5V

Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 26 – Arduino KY-010 Optical broken module
Let, Arduino KY-010 photo interrupter module. *******/
int Led = 13 ;// define LED Interface
int buttonpin = 3; // define the photo interrupter sensor interface
int val ;// define numeric variables val
void setup () {
pinMode (Led, OUTPUT) ;// define LED as output interface
pinMode (buttonpin, INPUT) ;// define the photo interrupter sensor output interface
}
void loop () {
val = digitalRead (buttonpin) ;// digital interface will be assigned a value of 3 to read val
if (val == HIGH) // When the light sensor detects a signal is interrupted, LED flashes
{
digitalWrite (Led, HIGH);
}
else {
digitalWrite (Led, LOW);
}
}
Step 3: Compile the program and upload to Arduino UNO board.

Lesson 27 – Arduino KY-039 Detect the heartbeat


module
Overview:
In this tutorial we have to study bright infrared (IR) LED and a phototransistor to detect the pulse
of the finger, a red LED flashes with each pulse .

Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-039 heartbeat module
 1 x Breadboard
 Jumper wires
Principle:
This project uses bright infrared (IR) LED and a phototransistor to detect the pulse of the finger,
a red LED flashes with each pulse. Pulse monitor works as follows: The LED is the light side of the
finger, and phototransistor on the other side of the finger, phototransistor used to obtain the
flux emitted, when the blood pressure pulse by the finger when the resistance of the photo
transistor will be slightly changed. The project's schematic circuit as shown, we chose a very high
resistance resistor R1, because most of the light through the finger is absorbed, it is desirable
that the phototransistor is sensitive enough. Resistance can be selected by experiment to get the
best results. The most important is to keep the shield stray light into the phototransistor. For
home lighting that is particularly important because the lights at home mostly based 50HZ or
60HZ fluctuate, so faint heartbeat will add considerable noise.
When running the program the measured values are printed. To get a real heartbeat from this
could be challenging.

Schematic:
 Sensor pin S connect to Arduino pin Analoog 0 / A0
 Sensor pin + (middle pin) connect to Arduino pin 5+
 Sensor pin - connect to Arduino pin GND

Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 27 – Arduino KY-039 Detect the heartbeat module
Let, Arduino KY-010 the heartbeat module detect. *******/

int sensorPin = 0;
double alpha = 0.75;
int period = 100;
double change = 0.0;
double minval = 0.0;
void setup () {
Serial.begin (9600);
}
void loop () {
static double oldValue = 0;
static double oldChange = 0;
int rawValue = analogRead (sensorPin);
double value = alpha * oldValue + (1 - alpha) * rawValue;
Serial.print (rawValue);
Serial.print (",");
Serial.println (value);
oldValue = value;
delay (period);
}

Step 3: Compile the program and upload to Arduino UNO board.

Lesson 28 – Arduino KY-025 Reed module


Overview:
In this tutorial we have to study KY-025 Reed Switch Module for Arduino is a small electrical
switch operated by an applied magnetic field, commonly used as proximity sensor.

Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-025 Reed module
 1 x Breadboard
 Jumper wires
Principle:
Reed module and the interface comes with digital 13 LED build a simple circuit to produce a Reed
warning lamp 13 comes with digital interfaces of the LED, the Reed sensor access number 3
interface, when Reed sensors Sensed a key signal (magnetic field change near the module), LED
lights, otherwise off.

Schematic:
KY-025 Arduino
A0 A0
G GND
+ 5V
D0 2

Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 28 – Arduino KY-025 Reed module
Let, Arduino KY-025 Reed Switch Module.*******/

int led = 13; // define the LED pin


int digitalPin = 2; // KY-025 digital interface
int analogPin = A0; // KY-025 analog interface
int digitalVal; // digital readings
int analogVal; //analog readings
void setup() {
pinMode(led, OUTPUT);
pinMode(digitalPin, INPUT);
//pinMode(analogPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// Read the digital interface
digitalVal = digitalRead(digitalPin);
if(digitalVal == HIGH) // if magnetic field is detected
{
digitalWrite(led, HIGH); // turn ON Arduino's LED
}
else {
digitalWrite(led, LOW); // turn OFF Arduino's LED
}
// Read the analog interface
analogVal = analogRead(analogPin);
Serial.println(analogVal); // print analog value to serial
delay(100);
}
Step 3: Compile the program and upload to Arduino UNO board.

Lesson 29 – Obstacle avoidance sensor module KY-032


Overview:
In this tutorial we have to study IR (infrared) obstacle detection is to transmit the IR signal
(radiation) in a direction and a signal is received at the IR receiver when the IR radiation bounces
back from a surface of the object.

Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-032 obstacle avoidance sensor module
 1 x Breadboard
 Jumper wires
Principle:
This Infrared Obstacle Avoidance Sensor returns a signal when it detects an object in range. The
range of the sensor is around 2-40 cm is distance. It operates at 3.5 to 5 volts at around 20
milliamps. The Obstacle Avoidance Sensors usually come in two types - with 3 and 4 pins. The 3
pin version does not have the ability to be enabled/disabled. The 4 pin version has optional
Enable pin. Infrared obstacle avoidance sensor is designed to detect obstacles or the difference
in reflective services. One application is to help a wheeled robot avoid obstacles with a sensor to
react to adjustable distance settings. This device has an infrared transmitter and receiver that
forms the sensor pair. The transmitter LED emits a certain frequency of infrared, which the
receiver LED will detect. The receiving LED will detect some of the signal back and will trigger the
digital on/off “signal” pin when a specific threshold “distance” has been detected. Most boards
will have 2 potentiometers, one of which is to adjust how sensitive the sensor is. You can use it
to adjust the distance from the object at which the sensor detects it. Typically, the other
potentiometer, which changes the transmitter IR frequency is not adjusted.

Schematic:

KY-025 Arduino
G GND
VCC 5V
Output 7
Enable -

Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 29 – Obstacle avoidance sensor module KY-032
Let, Arduino KY-032 obstacle avoidance sensor.*******/

int LED = 13; // Use the onboard Uno LED


int isObstaclePin = 7; // This is our input pin
int isObstacle = HIGH; // HIGH MEANS NO OBSTACLE
void setup() {
pinMode(LED, OUTPUT);
pinMode(isObstaclePin, INPUT);
Serial.begin(9600);
}
void loop() {
isObstacle = digitalRead(isObstaclePin);
if (isObstacle == LOW) {
Serial.println("OBSTACLE!!, OBSTACLE!!");
digitalWrite(LED, HIGH);
} else {
Serial.println("clear");
digitalWrite(LED, LOW);
}
delay(200);
}
Step 3: Compile the program and upload to Arduino UNO board.

Lesson 30 – Arduino Hunt Sensor module KY-033


Overview:
In this tutorial we have to study Infrared obstacle avoidance sensor is designed for the design of
a wheeled robot obstacle avoidance sensor distance adjustable.

Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-033 Hunt sensor module
 1 x Breadboard
 Jumper wires
Principle:
Infrared obstacle avoidance sensor is designed for the design of a wheeled robot obstacle
avoidance sensor distance adjustable. This ambient light sensor adaptable, high precision, having
a pair of infrared transmitter and receiver, transmitter tubes emit a certain frequency of
infrared,When detecting the direction of an obstacle (reflector), the infrared receiver tube
receiver is reflected back, when the indicator is lit,Through the circuit, the signal output interface
output digital signal that can be detected by means of potentiometer knob to adjust the distance,
the effective distance from 2 ~ 40cm, working voltage of 3.3V-5V, operating voltage range as
broad, relatively large fluctuations in the power supply voltage of the situation stable condition
and still work for a variety of microcontrollers,Arduino controller, BS2 controller,attached to the
robot that can sense changes in their surroundings.

Schematic:

KY-033 Arduino
GND GND
V+ 5V
Output 3

Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 30 - Arduino Hunt Sensor module KY-033
Let, Arduino KY-033 Hunt sensor Module.*******/

int led = 13; //LED pin


int sensor = 3; //sensor pin
int val; //numeric variable
void setup() {
pinMode(Led, OUTPUT); //set LED pin as output
pinMode(sensor, INPUT); //set sensor pin as input
}
void loop() {
val = digitalRead(sensor); //Read the sensor
if(val == HIGH) { digitalWrite(Led, HIGH); }
else { digitalWrite(Led, LOW); }
}
Step 3: Compile the program and upload to Arduino UNO board.
Lesson 31 – Arduino KY-001 Temperature Sensor
DS18B20 module
Overview:
In this tutorial we have to study DS18B20 digital thermometer provides 9-bit to 12-bit Celsius
temperature measurements and has an alarm function with nonvolatile user-programmable
upper and lower trigger points.

Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-001 DS18B20 Sensor Module
 1 x Breadboard
 Jumper wires
Principle:

The DS18B20 digital thermometer provides 9-bit to 12-bit Celsius temperature measurements
and has an alarm function with nonvolatile user-programmable upper and lower trigger points.
The DS18B20 communicates over a 1-Wire bus that by definition requires only one data line (and
ground) for communication with a central micro-processor. In addition, the DS18B20 can derive
power directly from the data line (“parasite power”), eliminating the need for an external power
supply. Each DS18B20 has a unique 64-bit serial code, which allows multiple DS18B20s to
function on the same 1-Wire bus. Thus, it is simple to use one microprocessor to control many
DS18B20s distributed over a large area. Applications that can benefit from this feature include
HVAC environmental controls, temperature monitoring systems inside buildings, equipment, or
machinery, and process monitoring and control systems.
Schematic:

KY-001 Arduino
GND GND
V+ 5V
Output 2

Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 31 – Arduino KY-001 Temperature Sensor DS18B20 module
Let, Arduino KY-001 Temperature Sensor DS18B20 module .*******/
#include <OneWire.h>
OneWire ds(2); // on pin 2
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
int HighByte, LowByte, TReading, SignBit, Tc_100, Whole, Fract;
byte i;
byte present = 0;
byte data[12];
byte addr[8];
if ( !ds.search(addr)) {
Serial.print("No more addresses.\n");
ds.reset_search();
return;
}
Serial.print("R=");
for( i = 0; i < 8; i++) {
Serial.print(addr[i], HEX);
Serial.print(" ");
}
if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.print("CRC is not valid!\n");
return;
}
if ( addr[0] == 0x10) {
Serial.print("Device is a DS18S20 family device.\n");
}
else if ( addr[0] == 0x28) {
Serial.print("Device is a DS18B20 family device.\n");
}
else {
Serial.print("Device family is not recognized: 0x");
Serial.println(addr[0],HEX);
return;
}
ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end
delay(1000); // maybe 750ms is enough, maybe not
present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratch pad
Serial.print("P=");
Serial.print(present,HEX);
Serial.print(" ");
for ( i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
Serial.print(data[i], HEX);
Serial.print(" ");
}
Serial.print(" CRC=");
Serial.print( OneWire::crc8( data, 8), HEX);
Serial.println();
LowByte = data[0];
HighByte = data[1];
TReading = (HighByte << 8) + LowByte;
SignBit = TReading & 0x8000; // test most sig bit
if (SignBit) // negative
{
TReading = (TReading ^ 0xffff) + 1; // 2's comp
}
Tc_100 = (6 * TReading) + TReading / 4; // multiply by (100 * 0.0625) or 6.25
Whole = Tc_100 / 100; // separate off the whole and fractional portions
Fract = Tc_100 % 100;
Serial.print("Temprature:");
if (SignBit) // If its negative
{
Serial.print("-");
}
Serial.print(Whole);
Serial.print(".");
if (Fract < 10) {
Serial.print("0");
}
Serial.print(Fract);
Serial.print("\n");
}
Step 3: Compile the program and upload to Arduino UNO board.
Lesson 32 – Arduino KY-024 Linear Magnetic Hall Sensor
Overview:
In this tutorial we have to study the module has both digital and analog outputs, there's a
potentiometer to adjust the detection threshold on the digital interface.

Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-024 Linear Magnetic Hall Sensor
 1 x Breadboard
 Jumper wires
Principle:
Linear Hall magnetic module and a digital interface, built-in 13 LED build a simple circuit to
produce a magnetic field warning lamp 13 comes with digital interfaces of the LED, the linear Hall
sensor magnetometer access number 3 interface, when linear Hall magnetometer Sensor senses
a key signal, LED lights, otherwise off.
Schematic:

KY-028 Arduino
A0 A0
G GND
+ 5v
D0 2

Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 32 – Arduino KY-024 Linear Magnetic Hall Sensor
Let, Arduino KY-024 linear magnetic hall sensor.*******/
int led = 13; // define the LED pin
int digitalPin = 2; // KY-024 digital interface
int analogPin = A0; // KY-024 analog interface
int digitalVal; // digital readings
int analogVal; //analog readings
void setup() {
pinMode(led, OUTPUT);
pinMode(digitalPin, INPUT);
//pinMode(analogPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// Read the digital interface
digitalVal = digitalRead(digitalPin);
if(digitalVal == HIGH) // if temperature threshold reached
{
digitalWrite(led, HIGH); // turn ON Arduino's LED
}
else{
digitalWrite(led, LOW); // turn OFF Arduino's LED
}
// Read the analog interface
analogVal = analogRead(analogPin);
Serial.println(analogVal); // print analog value to serial
delay(100);
}
Step 3: Compile the program and upload to Arduino UNO board.
Lesson 33 – Arduino KY-036 Metal touch sensor module

Overview:
In this tutorial we have to study the touch sensor (mosfet) will generate an output when the
metal leg of the mosfet is touched.

Components:
 1 x Arduino uno
 1 x USB Cable
 1 x KY-036 Metal touch sensor
 1 x Breadboard
 Jumper wires
Principle:
Metal Touch Interface module and number 13 comes with LED build a simple circuit to produce
a touch cue lights 13 comes with digital interfaces of the LED, the metal touch sensor connected
digital three interfaces, when a metal touch Sensor senses a key signal, LED ights, otherwise off.
Schematic:

KY-028 Arduino
A0 A0
G GND
+ 5v

Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 33 – Arduino KY-036 Metal touch sensor module
Let, Arduino KY-036 Metal touch sensor module.*******/
int touchPin = A0;
int sensorValue = 0;

void setup ()
{
Serial.begin (9600);
}

void loop ()
{
sensorValue = analogRead (touchPin);
Serial.println (sensorValue, DEC);
delay (1000);
}
Step 3: Compile the program and upload to Arduino UNO board.

Lesson 34 – Arduino KY-028 Temperature sensor


module
Overview:
In this tutorial we have to study this module has both digital and analog outputs, there's a potentiometer
to adjust the detection threshold on the digital interface.

Components:

 1 x Arduino uno
 1 x USB Cable
 1 x KY-028 Temperature sensor module
 1 x Breadboard
 Jumper wires
Principle:
Digital temperature module and a digital interface, built-in 13 LED build a simple circuit, making
the temperature warning lamp 13 comes with digital interfaces of the LED, the digital
temperature sensor connected digital three interfaces, when the digital temperature Sensor
senses a key signal, LED lights, otherwise off.
Schematic:

KY-028 Arduino
A0 Pin A0
G GND
+ 5v
D0 Pin 2

Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 34 – Arduino KY-028 Temperature sensor module
Let, Arduino KY-028 Temperature sensor module.*******/
int led = 13; // define the LED pin
int digitalPin = 2; // KY-028 digital interface
int analogPin = A0; // KY-028 analog interface
int digitalVal; // digital readings
int analogVal; //analog readings
void setup() {
pinMode(led, OUTPUT);
pinMode(digitalPin, INPUT);
//pinMode(analogPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// Read the digital interface
digitalVal = digitalRead(digitalPin);
if(digitalVal == HIGH) // if temperature threshold reached
{
digitalWrite(led, HIGH); // turn ON Arduino's LED
}
else {
digitalWrite(led, LOW); // turn OFF Arduino's LED
}
// Read the analog interface
analogVal = analogRead(analogPin);
Serial.println(analogVal); // print analog value to serial
delay(100);
}
Step 3: Compile the program and upload to Arduino UNO board.

Lesson 35 – Mercury open optical module KY-017

Overview:
In this experiment, we will learn how to use Mercury Switch.

Components:
 1 x Arduino uno
 1 x USB Cable
 1 x Mercury Switch KY-017
 1 x Breadboard
 Jumper wires
Principle:
Mercury Switch and number 13 port have the built-in LED simple circuit. To produce a switch
flasher, we can use connect the digital port 13 to the built-in LED and connect the Mercury Switch
S port to number 3 port of Arduino Uno board. When the tilt switch sensing, LED twinkle light to
the switch signal.
Schematic:

KY-017 Arduino
S Pin 3
Middle +5v
G GND

Procedure:
Step 1: Build the circuit

Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 35 – Mercury open optical module KY-017
Let, Arduino KY-017 Mercury open optical module.*******/
int led_pin = 13; // Define the LED interface
int switch_pin = 3; // Definition of mercury tilt switch sensor interface
int val; // Defines a numeric variable
void setup() {
pinMode(led_pin, OUTPUT);
pinMode(switch_pin, INPUT);
}
void loop() {
val = digitalRead(switch_pin); // check mercury switch state
if(val == HIGH)
{
digitalWrite(led_pin, HIGH);
}
else {
digitalWrite(led_pin, LOW);
}
}
Step 3: Compile the program and upload to Arduino UNO board.

Lesson 36 – Automatic flashing colorful LED module KY-


034
Overview:
In this experiment, we will learn how to use the Automatic flashing colorful LED module.
Components:
 1 x Arduino uno
 1 x USB Cable
 1 x Flashing colorful LED module KY-034
 1 x Breadboard
 Jumper wires
Principle:
If you connect this module with a power supply, a LED will light up which changes its colour
automatically. It includes 7 different colours.

Schematic:

KY-034 Arduino
G GND
N.C -
S

Procedure:
Step 1: Build the circuit
Step 2: Program: Open /Copy the code from the “CODE” Folder
/***********************************************************
File name: 36 – Automatic flashing colorful LED module KY-034
Let, Arduino 7 color flash LED module.*******/
int Led = 13;

void setup () {
pinMode (Led, OUTPUT); // Initialization of the LED output pin
}
void loop () {
digitalWrite (Led, HIGH); // LED will be switched on
delay (4000); // waitmode for 4 seconds
digitalWrite (Led, LOW); // LED will be switched off
delay (2000); // waitmode for another 2 seconds
}
Step 3: Compile the program and upload to Arduino UNO board.
Lesson 37 –Sensitive microphone sensor module KY-037
Overview:
In this experiment, we will learn how to use the sensitive microphone Sensor.

Components:
 1 x Arduino uno
 1 x USB Cable
 1 x Sensitive microphone sensor module KY-037
 1 x Breadboard
 Jumper wires
Principle:
The sensitive microphone 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
/***********************************************************
File name: 37 –Sensitive microphone sensor module KY-037
Let, Arduino sensitive voice sensor module .*******/
int Led = 13 ;// define LED Interface
int buttonpin = 2; // define D0 Sensor Interface
int val = 0;// define numeric variables val

void setup () {
pinMode (Led, OUTPUT) ;// define LED as output interface
pinMode (buttonpin, INPUT) ;// output interface D0 is defined sensor
}
void loop () {
val = digitalRead(buttonpin);// digital interface will be assigned a value of pin 3 to read val
if (val == HIGH) // When the sound detection module detects a signal, LED flashes
{
digitalWrite (Led, HIGH);
}
else {
digitalWrite (Led, LOW);
}
}
Step 3: Compile the program and upload to Arduino UNO board.

You might also like