0% found this document useful (0 votes)
8 views194 pages

TOP 10 Arduino Avec Capteurs

Uploaded by

bbc pipo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views194 pages

TOP 10 Arduino Avec Capteurs

Uploaded by

bbc pipo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

TOP 10 Arduino-Sensors with Projects for Beginners

>Arduino
So you are a beginner and want to work on different sensors but don‟t know where to start? Here is the list of “TOP 10
Arduino-Sensors with Projects for Beginners” for you to get started.

In this post we have listed the most popular and widely used sensors plus one or more project based on each sensor. Before
you go through the post I want you to know that projects listed below are selected very carefully by keeping in mind each
and every aspect.

10. Touch Sensor

touch sensor

About: Unlike pushbuttons, a touch sensor is activated due to physical contact. It is highly sensitive and can sense different
touch modes i.e single tapping, long touch and swipe etc.
Project: Touch Dimmer circuit using Arduino

Touch dimmer switch circuit using Arduino

Objective: In this project, the brightness of a small bulb is controlled using a touch sensor. Longer the touch time brighter
the bulb glows. So brightness of the bulb is adjusted in accordance with the touch time.

Electronic Components you need for this project are:

[Link] Board x 1

2. Touch Sensor

3. 2N2222 NPN Transistor

4. 1 Kohm Resistor
5. Small Bulb

6. Power Supply

7. Breadboard for connections

5. Connecting Wires

Link to the project site is given below:

Touch dimmer circuit

9. Temperature Sensor LM35

LM35 Temperature Sensor


About: LM35 is one of the popular temperature IC. It is used to measure surroundings temperature in the form of analog
voltage.

Project: Temperature measurement using LM35

Arduino Thermometer using LM35

Objective: To measure and display the temperature of surroundings using LM35 temperature sensor on LCD display.

LM35 measures the temperature and sends this in the form of analog voltage to Arduino. This temperature value is then
displayed on LCD display.

Electronic Components you need for this project are:


1) 1 x Arduino UNO (can be any Arduino board)

1) 1 x 16×2 LCD

2) 1 x LM35 Temperature Sensor

3) 1 x Breadboard

4) 1 x USB Cable

5) 1 x 10k Potentiometer

6) 1 x 220-ohm resistor

7) 1 x 9V Battery and clip (optional, for more portability)

Link to the project site is given below:

Arduino Thermometer

8. Light Dependent Resistor(LDR)


LDR

About: LDR or Light Dependent Resistor changes its resistance according to the intensity of light that falls on it. The
resistance value is inversely proportional to the intensity of light.

Project 1: Using LDR to control the ON/OFF status of a bulb.

Controlling Status of Bulb using LDR


OBJECTIVE: To control the state of a bulb using LDR and Relay with Arduino.

As soon as the intensity of light decreases below a certain value, status of bulb changes from OFF to ON.

Electronic Components you need for this project are:

1) Arduino Uno

2) LDR

3) SPDT Relay

4) Connecting Wires

Link to the project site is given below:

LDR-Arduino

Project 2: Suntracker using 4 LDR with Arduino


Suntracker using LDR and Servo motor with Arduino

OBJECTIVE: To build an Arduino-Servo controlled mechanism that follows the sun as it moves in the horizon.

Solar Panels can be attached to the front so that maximum sunlight get absorbed by them at any instant. Since Arduino-
Sunflower acts like a real Sunflower in presence of sunlight, it is called an electronic Sundancer!

This project was posted by Elecrow on [Link]

Components you need for this project are:

1) Arduino Board

2) LDR(Light dependent resistors) X 4

3) Connecting Wires

4) Linear Potentiometer X 4
5) Base Shield For Arduino

6) Cardboard

7) Foamboard

8) Stick

9) Servo Motor

Link to the project site is given below:

Arduino Sunflower

Un grand projet ici [Link]

7. Humidity plus Temperature Sensor Module


Humidity Sensor

About: This sensor module measures the humidity and temperature of the surroundings.

Project: Humidity and Temperature measurement

Temperature and humidity measurement using humidity sensor

OBJECTIVE: To measure the humidity and temperature of surrounding using Humidity sensor with Arduino and then print
the value on LCD display.

Electronic Components you need for this project are:

1) Arduino Uno

2) DHT11 Humidity and Temperature sensor module

3) 16×2 LCD display

4) 10k Ohm potentiometer

5) 5kohm resistor

6) Power supply

7) Breadboard for connection

8) Connecting Wires

Link to the project site is given below:

Humidity Sensor Module


6. Moisture Sensor

Moisture Sensor

About: Moisture sensor detects the level of moisture present in surroundings and hence commonly used in plant Irrigation
type projects.

Projects: Sensing Soil Moisture amount


Soil Moisture measurement using Arduino

OBJECTIVE: To measure the soil moisture content and print it on Serial Monitor of Arduino IDE.

Electronic Components you need for this project are:

1) Arduino Uno

2) Moisture Sensor

3) Breadboard for connections

4) Connecting wires

Link to the project page is given below:


Arduino Soil Moisture Sensor

5. Water / Rain / Liquid Sensor Module

Rain Sensor Module

About: Rain Sensor senses the droplets of water on its detector plate.

PROJECT: Arduino Rain Water Alarm

OBJECTIVE: To detect the water droplets by- Blinking LED and a buzzer.
Components you need for this project are:

[Link] Uno
2. Rain Sensor
3. Buzzer
4. LED

Link to the project site is given below:

Liquid Sensor Module

4. Accelerometer Sensor
Accelerometer Sensor

About: Accelerometer measures the acceleration in one to three axis and thus can be used to sense tilt movements.

PROJECT: Accelerometer-based gesture controlled Robot using Arduino.

OBJECTIVE: To build an accelerometer-based gesture controlled robot using Arduino.

Components you need for this project are:

1. Arduino UNO
2. Accelerometer
3. DC Motors
4. HT12D
5. HT12E
6. L293d Motor Driver
7. RF Module
2. 9v Battery
3. Robot Chasis
4. Connecting Wires

Link to the project site is given below:

Hand Gesture Controlled


Robot

3. IR Infrared Obstacle Avoidance Sensor Module

IR Infrared Obstacle Avoidance Sensor Module


About: Rain Sensor senses the droplets of water on its detector plate.

PROJECT 1: IR Sensor based Line Follower

Arduino Line Follower

OBJECTIVE: To build a Line Follower Robot using two IR sensor with Arduino.

Components you need for this project are:

1. Arduino UNO
2. Motor Driver L293D
3. Geared DC Motors
4. IR Sensor Module x 2
5. Power Supply
6. Connecting Wires

Link to the project site is given below:

IR Sensor based Line Follower

PROJECT 2: IR Sensor based Motion Sensing-Alarm

OBJECTIVE: To build a motion sensing alarm with an Arduino and IR sensors.

Components you need for this project are:

1. Arduino Board
2. Buzzer
3. 470 Ohm Resistor
4. IR Sensor Module x 2
5. Power Supply
6. NPN transistor
7. Pushbutton
8. Connecting Wires

Link to the project site is given below:

IR Sensor based Motion Sensor


Alarm

2. Ultrasonic Sensor

HC-SR04 Ultrasonic Sensor


About: An Ultrasonic Sensor sends and receives the Sound Waves.

PROJECT 1: Door Alarm using Ultrasonic Sensor

OBJECTIVE: To build a Door Alarm using Ultrasonic Sensor with Arduino

Components you need for this project are:

1. Arduino Board
2. Buzzer
3. HC-SR04 Ultrasonic Sensor
4. Breadboard for connection
4. Connecting Wires

Link to the video source is given below:

Arduino Door Alarm

PROJECT 2: Distance Measurement using Ultrasonic Sensor and Arduino.


OBJECTIVE: To build a Door Alarm using Ultrasonic Sensor with Arduino

Components you need for this project are:

1. Arduino Board
2. LCD Display
3. HC-SR04 Ultrasonic Sensor
4. Breadboard for connection
4. Connecting Wires

Link to the video source is given below:

Measuring Distance using


HC-SR04 Sensor

PROJECT 3: Arduino Based Smart Blind Stick


Smart Blind Stick Using Arduino

OBJECTIVE: To make a circuit using Ultrasonic sensor and Arduino which indicates the object in front by producing a
beep sound.

This circuit can act as a smart blind stick if fitted onto a stick. The frequency of beep sound increases as stick goes closer
and closer to the obstacle. Also, Circuit has an LDR to sense light intensity and an RF remote to locate Stick remotely.

Ultrasonic Sensor is the heart of this Arduino based Alarm stick. It senses the distance of obstacle and sends this data to
Arduino. Arduino further processes this data and thus determine the frequency with which buzzer produce sound.

Components you need for this project are:


1. Arduino Board

2. Ultrasonic Sensor HC-SR04

3. Buzzer and LED

4. Voltage Regulator L7805

5. LDR

6. 433 MHz transmitter and receiver

7. Perf Board

8. Push button

9. Battery(9 Volt)

Link to the project site is given below:

Smart Blind Stick

1. HC-SR501 Pyroelectric Infrared Sensor Module


HC-SR501 Pyroelectric Infrared Sensor Module

About: Pyroelectric Infrared Sensor or PIR Sensor senses the heat energy emitted by a human body in the form of Infrared
Radiation.

PROJECT: Using a PIR sensor with Arduino to Control home appliances.

OBJECTIVE: To interface a PIR Sensor with Arduino and then control(ON/OFF) home appliances
Components you need for this project are:

1. Arduino Board

2. HC-SR501

3. 2 Channel Relay Module

4. A.C Appliance

Link to the project Site is given below:

PIR Sensor-Arduino

Similar Post:
 Top 10 Arduino Projects You Must Know About In 2018 | Best ever
 Top 10 Arduino Projects For Beginners in 2018 (Honest Opinion)
 Top 10 Arduino Projects On Instructables till 2018 (Best Ever)
 Top 10 IoT (Internet Of Things) Projects You can Make in 2018

Share this:
Dimmer Switch = variateur d'ambiance
10Touch Dimmer Switch Circuit using Arduino
March 11, 2017 By Anusha 14 Comments

A Touch Dimmer Switch Circuit is a simple project, where the dimmer action is achieved with the help of a Touch Sensor. While a regular
switch is used to simply turn ON or OFF a light, a Dimmer (or Dimmer Switch) will allow us to control the brightness of the light. Without a
Dimmer Switch, the light bulbs tend to glow at full brightness consuming maximum power. If full brightness is not required, then Dimmer
Switches can be used and save some energy. With the help of a Dimmer Switch, we can vary the brightness from fully off to fully on.

Different light bulbs need different dimmer switches and there are different types of Dimmer Switches available in the market. Some of the
commonly found Dimmer Switches are Slider type and rotary type.

In this project, we have designed a Touch Dimmer Switch using Arduino. The Touch Dimmer Switch Circuit is implemented using a Touch
Sensor. The circuit design, components and working of the project is explained in the following sections.
touch dimmer switch3
touch dimmer switch 1
touch dimmer switch 2
touch dimmer switch3
touch dimmer switch 1

Table of Contents

 Circuit Diagram of Touch Dimmer Switch Circuit


 Components Required for Touch Dimmer Switch Circuit
 Component Description
 How to Design Touch Dimmer Switch Circuit ?
 Working of the Touch Dimmer Switch Circuit
 Code
 Applications
 Construction and Output Video

Circuit Diagram of Touch Dimmer Switch Circuit


Components Required for Touch Dimmer Switch Circuit

 Arduino UNO
 Touch Sensor
 2N2222 NPN Transistor
 Small Bulb
 1 KΩ Resistor
 Power supply
 Breadboard (Prototyping board)
 Connecting Wires

Component Description

Arduino UNO: In this project, Arduino UNO is used to detect the output from the touch sensor and correspondingly drive the bulb.

Touch Sensor: A Touch Sensor is a type of sensor that detects physical touch or proximity. They are input devices like buttons and switches but
are more sensitive than those two. Hence, touch sensors are replacing buttons in devices like mobile phones and laptops.

There are different types of touch sensors like resistive touch sensors, capacitive touch sensors, piezo touch sensors etc. The most common one is
the capacitive type touch sensor and we have used one in this project.

The advantage of touch sensors is that with a single sensor, we can get multiple operations like swipe, tap and pinch. The working of a touch
sensor (Capacitive type to be specific) is simple.

Basically, it detects the change in capacitance of the sensor when we touch it. Additionally, some sensors can detect these changes in capacitance
without the physical contact but when the finger is placed slightly near to the sensor.
The touch sensor used in this project is based on TTP223 Touch Pad Detector IC. This particular IC can detect 1 key touch and the sensor can be
used as replacement for traditional button in a wide range of consumer products. For additional information regarding the Touch Pad Detector IC
and the circuit of the touch sensor, refer the datasheet of TTP223.

The output of the touch sensor will be logic HIGH when we place our finger on the touch plate. We will use this logic in the programming part of
the Arduino.

How to Design Touch Dimmer Switch Circuit ?


The design of the Touch Dimmer Switch Circuit is very simple and is explained here. The touch sensor is given the power supply by connecting
5V to VCC and ground to GND pins. The SIG pin of the touch sensor is connected to any of the digital input / output pin of the Arduino UNO
board. Here, it is connected to digital I/O pin 8.

Next, we will connect a small incandescent bulb that glows on DC. The bulb is interface with the Arduino UNO board with the help of a
transistor. So, first connect the base of a transistor like 2N2222 to any digital I/O pin of Arduino UNO with the help of a current limiting resistor.

Then connect the collector terminal of the transistor to the 5V power supply. And finally, connect a bulb between the emitter and ground
terminals. This completes the design of the circuit.

Working of the Touch Dimmer Switch Circuit

As mentioned earlier, there are many types of dimmer switches for different types of bulbs. In this project, a simple touch dimmer switch circuit
is designed. The working of the project is explained here.

When the sensor is not touched, the SIG pin of the sensor remains LOW. Whenever we touch the sensitive part of the touch sensor, the SIG pin
of the sensor goes HIGH. Since it is connected to Arduino UNO, we will detect this change in state i.e. LOW to HIGH.

So, when the finger is placed on the touch sensor, Arduino UNO detects the change in the logic state of the sensor‟s output and drive the bulb
using Pulse Width Modulation (PWM). Hence, the bulb is connected to a PWM pin of the Arduino UNO.

As we continue to place the finger on the touch sensor, Arduino UNO slowly increases the intensity of the bulb with the help of PWM. In the
project, we used a tiny bulb as shown in the following image instead of a big incandescent bulb.
This process continues until the finger is lifted or maximum brightness is reached i.e. the bulb is fully ON. In order to decrease the brightness of
the bulb, double tap and on the double tap, continue to place the finger on the touch sensor.

Arduino UNO is programmed such that, if a double tap is detected (two touches with a very small delay) it has to reduce the brightness of the
bulb and thus acting as a dimmer switch.
Similar logic of PWM is used for reducing the brightness of the bulb where, when continued to place the finger on the double tap (tap once and
tap and hold the finger on second tap), the intensity of the bulb gradually decreases until the finger is lifted or the bulb reaches minimum
brightness i.e. it is completely OFF. This is how a Touch Dimmer Switch circuit using Arduino works.

Code

int led = 3;
int sen=8;
int val=0;
void setup()
{
pinMode(sen,INPUT);
pinMode(led,OUTPUT);

digitalWrite(sen,LOW);
digitalWrite(led,LOW);

void loop()
{
while(digitalRead(sen)==LOW);
while(digitalRead(sen)==HIGH)
{
while(digitalRead(sen)==HIGH)
{
if(val<=255)
{
analogWrite(led,val);
val++;
delay(15);
}
}

delay(1000);

while(digitalRead(sen)==HIGH)
{
if(val>=0)
{
analogWrite(led,val);
val--;
delay(15);
}
}
}
}

view raw Touch Dimmer Switch Circuit using Arduino hosted with by GitHub
Applications

 A simple Digital Touch Dimmer Switch Circuit is implemented in this project with the help of a Touch Sensor and Arduino UNO.
 This Touch Dimmer Switch can be used to control the brightness of a bulb by simply touching the sensor.
 Can replace traditional Dimmer Switches like slide switch or rotary type switch for bulbs.
 In order to use the touch dimmer switch with AC incandescent bulbs, dedicated ICs like TT6061A can be used.

NOTE: Be cautious when using Touch Sensor based Dimmer Switch for AC incandescent bulbs.

9 x LM35 Temperature
Step 1: Parts Needed
1 x Arduino UNO (can be any Arduino board)

1 x Breadboard

1 x USB Cable

1 x 16x2 LCD

1 x LM35 Temperature Sensor

1 x 10k Potentiometer

1 x 220 ohm resistor

1 x 9V Battery and clip (optional, for more portability)

18 x Jumper wires

Allchips is an electronics components online service platform, you can buy all the components from them.
Step 2: Plugging the Parts Into the Breadboard
Insert the LCD, the potentiometer and the LM35 into the breadboard. Their locations doesn't matter, place them the way you like.
Step 3: Connecting the LCD
This is the hardest part - you need to make most of the connections now. They are as follows:

LCD Pin -> Arduino Pin

4 -> 12

6 -> 11

11 -> 5

12 -> 4

13 -> 3

14 -> 2

LCD Pin -> Rail of the breadboard

1,5,16 -> GND

2 -> 5V

15 -> 5V (using the 220 ohm resistor!)


Step 4: Connecting the Potentiometer and the LM35
Here, the connections are as follows:

Potentiometer

One of the sides goes to GND, the opposite one - to 5V. The middle pin connects to pin 3 of the LCD

LM35

See the picture above.

Please, make sure that you insert the sensor the right way! If you swap the connections, it will burn out!
Step 5: Uploading the Code
After connecting everything, plug in your Arduino to your PC and upload the code that I've pasted here. I've added a few comments to explain
some of the code.

Step 6: Done!
Enjoy your handmade thermometer. Feel free to modify the code at your liking and improve the project by adding more sensors and stuff :)

8 ldr
A simple project using an Arduino that automatically turn lights on when an LDR sensor detects darkness.





Wouldn‟t it be cool if we could eliminate darkness? In this Arduino project, I have posted a very simple project that focuses on eliminating
darkness. Whenever a room gets dark due to a fused bulb or any other factors, a light bulb automatically turns on. You can even use this as an
emergency lighting system. Use it to automatically turn a light on when there isn‟t sufficient light in a room.

In order to detect the intensity of light or darkness, we use a sensor called an LDR (light dependent resistor). The LDR is a special type of resistor
that allows higher voltages to pass through it (low resistance) whenever there is a high intensity of light, and passes a low voltage (high
resistance) whenever it is dark. We can take advantage of this LDR property and use it in our DIY Arduino LDR sensor project.
How Does It Work?

This system works by sensing the intensity of light in its environment. The sensor that can be used to detect light is an LDR. It's inexpensive, and
you can buy it from any local electronics store or online.

The LDR gives out an analog voltage when connected to VCC (5V), which varies in magnitude in direct proportion to the input light intensity on
it. That is, the greater the intensity of light, the greater the corresponding voltage from the LDR will be. Since the LDR gives out an analog
voltage, it is connected to the analog input pin on the Arduino. The Arduino, with its built-in ADC (analog-to-digital converter), then converts
the analog voltage (from 0-5V) into a digital value in the range of (0-1023). When there is sufficient light in its environment or on its surface, the
converted digital values read from the LDR through the Arduino will be in the range of 800-1023.

Arduino LDR Sensor working


Furthermore, we then program the Arduino to turn on a relay. Correspondingly, turn on an appliance (light bulb), when the light intensity is low
(this can be done by covering the surface of the LDR with any object), that is, when the digital values read are in a higher range than usual.

Arduino LDR Sensor Connections

First, you need to connect the LDR to the analog input pin 0 on the Arduino. You have to use a voltage divider configuration to do this. The
connection diagram for the Arduino is as given below.
Arduino LDR connections

One leg of the LDR is connected to VCC (5V) on the Arduino, and the other to the analog pin 0 on the Arduino. A 100K resistor is also
connected to the same leg and grounded.

Testing the Code for the Arduino LDR Sensor

After connecting the LDR to your Arduino, you can check for the values coming from the LDR via the Arduino. To do this, connect the Arduino
via USB to your PC and open up the Arduino IDE or software. Next, paste this code and upload it to your Arduino:

int sensorPin = A0; // select the input pin for LDR

int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
[Link](9600); //sets serial port for communication
}
void loop() {
sensorValue = analogRead(sensorPin); // read the value from the sensor
[Link](sensorValue); //prints the values coming from the sensor on the screen

delay(100);

After uploading the code, click the button on the Arduino IDE called “Serial monitor". This will open a new window, which prints different
values on the screen. Now, test out the sensor by blocking its surface from light and see what values you get on the serial monitor. This is how
the serial monitor looks:
Arduino LDR Sensor - Serial Monitor

Connecting the Relay to the Arduino

A relay is an electromechanical switch. It can be used to turn an appliance ON/OFF working on AC/DC. When the Arduino supplies HIGH
voltage (5V) to the relay, it turns it on (the switch is ON), otherwise, it remains off.

In this project, we used a 5V SPDT (single pole double throw) relay. One terminal of the relay coil is connected to the Arduino's digital pin 2 and
the other end to GND. We connected a light bulb to it as well. Since we are dealing with high power AC voltages, be sure to take proper
precautions. If you are still confused about connecting a relay to an appliance, read this article on Relay logic. The overall circuit is shown below.
Arduino LDR Sensor and Relay - Connection Diagram
After connecting the Arduino as shown above, we need to test it by uploading the final code to our Arduino. The final sketch can be found here.

In this sketch, we set a threshold light value as 700, but it can vary for your projects. You will need to find out the particular value at which the
light bulb should turn on. This needs to be done after testing it empirically. So basically, the Arduino turns on the light bulb (via the relay)
whenever the light intensity falls below 700. When it is above 700, it turns the light bulb off. Here's a video showing it in action.

2.
n the following days, I began to carry out my solar tracker project. I selected the crowtail as the microcontroller board, and picked up the
componets and accessories in our warehouse. Then, I assembled these parts together. At last, I tested with the led on my phone. You know what,
it worked perfectly.

I was so excited and posted the demo video on the social media. I was surprised that many people liked and shared this video, and some of them
even sent me messages saying that they want to make this projects too.

So I redid this projects and make a specific tutorial to let more people make this project. Here we go.

(The code we used is referred to geobruce's application: [Link] and we make adjustment for
pan- tilt use.)
Step 1: Preparation

The materials we need is listed below.

Cardboard x 2
Foam board x 1

Stick x 1

3 pin crowtail cable x 6

Crowtail- Linear Potentiometer x 2

Crowtail- Light Sensor x 4

Crowtail- Pan- Tilt x 1

Crowduino With ATMega 328 V1.1 x 1

Crowtail- Base Shield for Arduino x 1


Step 2: Make the Head of the Device
Firstly, we need to cut the two cardboards as the pictures shows, just for half of cardboard. Then the pieces of cardboards can be assembled as a
cross shape. At last, paste the stick with the cross, it will play a role as "head", and always point to the sun. On the other hand, it can make the
device beautiful and stable.

Step 3: Install 4 Light Sensors


Piercing 4 suitable holes to install the 4 sensors, then dig one mid-hole to thread the stick. I numberd these sensors so that we can distinguish
their different seat.

Step 4: Connect the Sensors With Cables

Use the glue gun to fix the stick to the foam, and then plug the cables into the sensors
Step 5: Fix the Stick to the Pan-tilt
2 More Images

We fix the stick to the pan-tilt. the seat of sensor should keep consistent with the picture. sensor “1“ and sensor ”2” located below site.

The pan-tilt is an assembled device with 9G servos. It can cotrol the vertical and horizontal rotation with 180 [Link] the the solar pannel on
the foam

At last fix the the solar pannel on the foam. (Notice: the two solar pannels is just for decoration, without power supply function.)
Step 6: Upload the Code
Take out our Crowduino and Crowtail- base shield then stacking them together. Before we start to connect the cables onto base board, we need to
upload the program code into crowduino, a micro usb cable is neccessary. Connect the crowduino to our computer, and open the Arduino IDE,
click here to download the code and open it with Arduino IDE, then upload.

(Notice that this code is written by geobruce, for more info check his site [Link] )

Step 7: Connect 4 Sensors to the Shield


Now we can start connections. At first, connect the cables of sensors to the shield, with the numbers one-one correspondence as above picture
shows.

1-4 cables: Cable "1" to A0; Cable "2" to A1; Cable "4" to A2; Cable "3" to A3.
Step 8: Connect the Potentiometer to the Shield
Connect two potentiometers to A4 and A5 socket of the shield.

There is no difference between the two potentiometers, but you should know that which one connect with the A4 port is acts the role of
controling the delay of reaction time, and A5 for servo rotational speed.
Step 9: Connect the Pan-tilt to the Shield

Down servo(Horizontal movement) connect with D9, up sevo(Vertical movement) connect with D10.
Step 10: How to Power It.
The crowduino is the main controller board of this project. We can power this board with an USB power bank or a DC adapter, It's depended on
you whether it is to be a mobile device or a fixed device.
Step 11: Have a Try!

Now, close the box, it seems that it can't wait to chase the sunlight, OK. take it easy baby, let's have a test for you now.

I take it to a dark room, then open the phone flshlight, WOW! look at this cute guy!

It looks difficult but is actually quite simple, just do it!And you may help him to looks more powerful and cool!
Attachments

 sunlight_tracker.ino

[Link]
Table of Contents

 Circuit Diagram
 Components Required
 Circuit Description
 Component Description
o DHT11 Temperature and Humidity Sensor
o Example
 Working of the Project
 CODE
 Applications
 Construction and Output Video

Circuit Diagram

The following circuit diagram shows all the necessary connections required to implement this project.
Components Required

 Arduino UNO
 DHT11 Temperature and Humidity Sensor
 Breadboard (or perfboard)
 Power supply
 16 x 2 LCD Display
 10K Ohm Potentiometer
 5K Ohm Resistor (1/4 W)
 Connecting wires
Circuit Description

We will see the circuit design of DHT11 interfacing with Arduino. The DHT11 Humidity and Temperature sensor comes in two variants: just the
sensor or a module.

The main difference is that the module consists of the pull – up resistor and may also include a power on LED. We have used a module in this
project and if you wish to use the sensor itself, you need to connect a 5K Ω pull – up resistor additionally.

Coming to the design, the data pin of the DHT11 Sensor is connected to the Pin 11 of Arduino. A 16 x 2 LCD display is used to display the
results. The control pins of LCD i.e. RS and E (Pins 4 and 6 on LCD) are connected to pins 4 and 5 of Arduino. The data pins of LCD i.e. D4 to
D7 (pins 11 to 14 on LCD) are connected to pins 0 to 3 on LCD.

NOTE: For ease of connection, we have connected the DHT11 Sensor Module at the ICSP pins of the Arduino as it provides adjacent VCC,
DATA and GND pins. This type of connection is not necessary and you can connect the data pin of sensor to normal Digital I/O pins.

Component Description

DHT11 Temperature and Humidity Sensor

DHT11 is a part of DHTXX series of Humidity sensors. The other sensor in this series is DHT22. Both these sensors are Relative Humidity (RH)
Sensor. As a result, they will measure both the humidity and temperature. Although DHT11 Humidity Sensors are cheap and slow, they are very
popular among hobbyists and beginners.
The DHT11 Humidity and Temperature Sensor consists of 3 main components. A resistive type humidity sensor, an NTC (negative temperature
coefficient) thermistor (to measure the temperature) and an 8-bit microcontroller, which converts the analog signals from both the sensors and
sends out single digital signal.

This digital signal can be read by any microcontroller or microprocessor for further analysis.
DHT11 Humidity Sensor consists of 4 pins: VCC, Data Out, Not Connected (NC) and GND. The range of voltage for VCC pin is 3.5V to 5.5V.
A 5V supply would do fine. The data from the Data Out pin is a serial digital data.

The following image shows a typical application circuit for DHT11 Humidity and Temperature Sensor. DHT11 Sensor can measure a humidity
value in the range of 20 – 90% of Relative Humidity (RH) and a temperature in the range of 0 – 500C. The sampling period of the sensor is 1
second i.e.

All the DHT11 Sensors are


accurately calibrated in the laboratory and the results are stored in the memory. A single wire communication can be established between any
microcontroller like Arduino and the DHT11 Sensor.

Also, the length of the cable can be as long as 20 meters. The data from the sensor consists of integral and decimal parts for both Relative
Humidity (RH) and temperature.

The data from the DHT11 sensor consists of 40 – bits and the format is as follows:
8 – Bit data for integral RH value, 8 – Bit data for decimal RH value, 8 – Bit data for integral Temperature value, 8 – Bit data for integral
Temperature value and 8 – Bit data for checksum.

Example

Consider the data received from the DHT11 Sensor is

00100101 00000000 00011001 00000000 00111110.

This data can be separated based on the above mentioned structure as follows

In order to check whether the received data is correct or not, we need to perform a small calculation. Add all the integral and decimals values of
RH and Temperature and check whether the sum is equal to the checksum value i.e. the last 8 – bit data.

00100101 + 00000000 + 00011001 + 00000000 = 00111110

This value is same as checksum and hence the received data is valid. Now to get the RH and Temperature values, just convert the binary data to
decimal data.

RH = Decimal of 00100101 = 37%

Temperature = Decimal of 00011001 = 250C

Working of the Project

A simple project is built using Arduino UNO and DHT11 Humidity and Temperature Sensor, where the Humidity and Temperature of the
surroundings are displayed on an LCD display.
After making the connections, we need not do anything as the program will take care of everything. Although there is a special library for the
DHT11 module called “DHT”, we didn‟t use it. If you want to use this library, you need to download this library separately and add it to the
existing libraries of Arduino.

The program written is based on the data timing diagrams provided in the datasheet. The program will make the Arduino to automatically read
the data from the sensor and display it as Humidity and Temperature on the LCD Display.

CODE

#include <LiquidCrystal.h>

LiquidCrystal lcd(4, 5, 0, 1, 2, 3);

byte degree_symbol[8] =

0b00111,

0b00101,

0b00111,

0b00000,

0b00000,

0b00000,
0b00000,

0b00000

};

int gate=11;

volatile unsigned long duration=0;

unsigned char i[5];

unsigned int j[40];

unsigned char value=0;

unsigned answer=0;

int z=0;

int b=1;

void setup()

[Link](16, 2);
[Link]("Temp = ");

[Link](0,1);

[Link]("Humidity = ");

[Link](1, degree_symbol);

[Link](9,0);

[Link](1);

[Link]("C");

[Link](13,1);

[Link]("%");

void loop()

delay(1000);
while(1)

delay(1000);

pinMode(gate,OUTPUT);

digitalWrite(gate,LOW);

delay(20);

digitalWrite(gate,HIGH);

pinMode(gate,INPUT_PULLUP);//by default it will become high due to internal pull up

// delayMicroseconds(40);

duration=pulseIn(gate, LOW);

if(duration <= 84 && duration >= 72)

while(1)
{

duration=pulseIn(gate, HIGH);

if(duration <= 26 && duration >= 20){

value=0;}

else if(duration <= 74 && duration >= 65){

value=1;}

else if(z==40){

break;}

i[z/8]|=value<<(7- (z%8));

j[z]=value;

z++;

}
answer=i[0]+i[1]+i[2]+i[3];

if(answer==i[4] && answer!=0)

[Link](7,0);

[Link](i[2]);

[Link](11,1);

[Link](i[0]);

z=0;

i[0]=i[1]=i[2]=i[3]=i[4]=0;

view raw DHT11_Arduino.ino hosted with by GitHub


6 moisture.
Step 1: Components Required
For this project, you will need :

 Arduino Uno
 Soil Moisture Sensor
 Hook up Wires
 Bread Borad.
Step 2: About the Soil Moisture Sensor

A typical Soil Moisture Sensor consist of two components. A two legged Lead, that goes into the soil or anywhere else where water content has
to be measured. This has two header pins which connect to an Amplifier/ A-D circuit which is in turn connected to the Arduino.

The Amplifier has a Vin, Gnd, Analog and Digital Data Pins. This means that you can get the values in both Analog and Digital forms.
Step 3: How Does the Sensor Work
Most soil moisture sensors are designed to estimate soil volumetric water content based on the dielectric constant (soil bulk permittivity) of
the soil. The dielectric constant can be thought of as the soil's ability to transmit electricity. The dielectric constant of soil increases as the water
content of the soil increases. This response is due to the fact that the dielectric constant of water is much larger than the other soil components,
including air. Thus, measurement of the dielectric constant gives a predictable estimation of water content.

Step 4: Connections
 Connect the two pins from the Sensor to the two pins on the Amplifier circuit via hook up wires.
 Connect the Vcc from the Amplifier to the 3.3V pin on the Arduino and the Gnd pin to the Gnd pin on the Arduino.
 Now connect the Analog Data Pin to the A0 pin on the Arduino (Since I'm interested in Analog Data).

Refer the Pictures and build the circuit.


Step 5: Code

For simply reading the values I'll be using the AnalogRead sketch from the Examples menu. You can modify the code as per your requirements.

void setup() {

// initialize serial communication at 9600 bits per second:

[Link](9600);

// the loop routine runs over and over again forever:

void loop() {

// read the input on analog pin 0:

int sensorValue = analogRead(A0);

// print out the value you read:

[Link](sensorValue);

delay(1); // delay in between reads for stability

Step 6: Output

After verifying the code, upload it to the board and open the serial monitor. You will see the sensor data on the monitor being changed when you
dip the sensor leads in water and when dry. You can use these values as threshold if you intend to trigger an action bases on these values.

That's All Folks !! Stay Tuned for More !


5. detecter pluie- rain code
Sur youtube [Link]
et code
[Link]
view

4. acelerometre
Accelerometer Based Hand Gesture Controlled Robot using
Arduino
By Saddam 123 Comments
Accelerometer Based Hand Gesture Controlled
Robot using Arduino

Robots are playing an important role in automation across all the sectors like construction, military, medical, manufacturing, etc. After
making some basic robots like line follower robot, computer controlled robot, etc, we have developed this accelerometer based gesture
controlled robot by using arduino uno. In this project we have used hand motion to drive the robot. For this purpose we have used accelerometer
which works on acceleration.
Required Components

1. Arduino UNO
2. DC Motors
3. Accelerometer
4. HT12D
5. HT12E
6. RF Pair
7. Motor Driver L293D
8. 9 Volt Battery
9. Battery Connector
10. USB cable
11. Robot Chasis

RF Pair:

A gesture controlled robot is controlled by using hand in place of any other method like buttons or joystick. Here one only needs to move hand
to control the robot. A transmitting device is used in your hand which contains RF Transmitter and accelero-meter. This will transmit command
to robot so that it can do the required task like moving forward, reverse, turning left, turning right and stop. All these tasks will be performed by
using hand gesture.

Here the most important component is accelerometer. Accelerometer is a 3 axis acceleration measurement device with +-3g range. This device is
made by using polysilicon surface sensor and signal conditioning circuit to measure acceleration. The output of this device is Analog in nature
and proportional to the acceleration. This device measures the static acceleration of gravity when we tilt it. And gives an result in form of motion
or vibration.

According to the datasheet of adxl335 polysilicon surface-micromachined structure placed on top of silicon wafer. Polysilicon springs suspend
the structure over the surface of the wafer and provide a resistance against acceleration forces. Deflection of the structure is measured using a
differential capacitor which incorporate independent fixed plates and plates attached to the moving mass. The fixed plates are driven by 180° out-
of-phase square waves. Acceleration deflects the moving mass and unbalances the differential capacitor resulting in a sensor output whose
amplitude is proportional to acceleration. Phase-sensitive demodulation techniques are then used to determine the magnitude and direction of the
acceleration.
Pin Description of accelerometer

1. Vcc 5 volt supply should connect at this pin.


2. X-OUT This pin gives an Analog output in x direction
3. Y-OUT This pin give an Analog Output in y direction
4. Z-OUT This pin gives an Analog Output in z direction
5. GND Ground
6. ST This pin used for set sensitivity of sensor

Circuit Diagram and Explanation

Gesture Controlled Robot is divided into two sections:

1. Transmitter part
2. Receiver part

In transmitter part an accelerometer and a RF transmitter unit is used. As we have already discussed that accelerometer gives an analog output so
here we need to convert this analog data in to digital. For this purpose we have used 4 channel comparator circuit in place of any ADC. By
setting reference voltage we gets a digital signal and then apply this signal to HT12E encoder to encode data or converting it into serial form and
then send this data by using RF transmitter into the environment.

At the receiver end we have used RF receiver to receive data and then applied to HT12D decoder. This decoder IC converts received serial data
to parallel and then read by using arduino. According to received data we drive robot by using two DC motor in forward, reverse, left, right and
stop direction.

Working
Gesture controlled robot moves according to hand movement as we place transmitter in our hand. When we tilt hand in front side, robot start to
moving forward and continues moving forward until next command is given.

When we tilt hand in backward side, robot change its state and start moving in backwards direction until other command is given.

When we tilt it in left side Robot get turn left till next command.

When we tilt hand in right side robot turned to right.

And for stopping robot we keeps hand in stable.


Circuit Diagram for Transmitter Section

Circuit Diagram for Receiver Section

Circuit for this hand gesture controlled robot is quite simple. As shown in above schematic diagrams, a RF pair is used for communication and
connected with arduino. Motor driver is connected to arduino to run the robot. Motor driver‟s input pin 2, 7, 10 and 15 is connected to arduino
digital pin number 6, 5, 4 and 3 respectively. Here we have used two DC motors to drive robot in which one motor is connected at output pin of
motor driver 3 and 6 and another motor is connected at 11 and 14. A 9 volt Battery is also used to power the motor driver for driving motors.

Program Explanation

In program first of all we have defined output pins for motors.

And then in setup we have given the directions to pin.

After this we read input by using „if statement‟ and perform relative operation.
There are total five conditions for this Gesture controlled Robot which are giving below:

Input for Arduino from


Movement of gesture
hand

Side D3 D2 D1 D0 Direction
Stable 0 0 0 0 Stop

Tilt right 0 0 0 1 Turn Right

Tilt left 0 0 1 0 Turn Left

Tilt back 1 0 0 0 Backward

Tilt front 0 1 0 0 Forward

We have writen the complete program according to the above table conditions. Below is the complete code.

Code:
#define FD 16
#define BD 17
#define LD 18
#define RD 19

#define m11 3
#define m12 4
#define m21 5
#define m22 6

void forward()
{
digitalWrite(m11, HIGH);
digitalWrite(m12, LOW);
digitalWrite(m21, HIGH);
digitalWrite(m22, LOW);
}

void backward()
{
digitalWrite(m11, LOW);
digitalWrite(m12, HIGH);
digitalWrite(m21, LOW);
digitalWrite(m22, HIGH);
}

void left()
{
digitalWrite(m11, HIGH);
digitalWrite(m12, LOW);
digitalWrite(m21, LOW);
digitalWrite(m22, LOW);
}
void right()
{
digitalWrite(m11, LOW);
digitalWrite(m12, LOW);
digitalWrite(m21, HIGH);
digitalWrite(m22, LOW);
}

void Stop()
{
digitalWrite(m11, LOW);
digitalWrite(m12, LOW);
digitalWrite(m21, LOW);
digitalWrite(m22, LOW);
}

void setup()
{
pinMode(FD, INPUT);
pinMode(BD, INPUT);
pinMode(LD, INPUT);
pinMode(RD, INPUT);

pinMode(m11, OUTPUT);
pinMode(m12, OUTPUT);
pinMode(m21, OUTPUT);
pinMode(m22, OUTPUT);
}

void loop()
{
int temp1=digitalRead(FD);
int temp2=digitalRead(BD);
int temp3=digitalRead(LD);
int temp4=digitalRead(RD);

if(temp1==1 && temp2==0 && temp3==0 && temp4==0)


backward();

else if(temp1==0 && temp2==1 && temp3==0 && temp4==0)


forward();

else if(temp1==0 && temp2==0 && temp3==1 && temp4==0)


left();

else if(temp1==0 && temp2==0 && temp3==0 && temp4==1)


right();

else
Stop();
}

[Link]
Suiveur ligne
[Link]
How To Make Arduino Line Follower Robot?
March 20, 2017 By Anusha 50 Comments

A Line Follower Robot, as the name suggests, is an automated guided vehicle, which follow a visual line embedded on the floor or ceiling.
Usually, the visual line is the path in which the line follower robot goes and it will be a black line on a white surface but the other way (white line
on a black surface) is also possible. Certain advanced Line Follower Robots use invisible magnetic field as their paths.

Large line follower robots are usually used in industries for assisting the automated production process. They are also used in military
applications, human assistance purpose, delivery services etc.

Line follower Robot is one of the first robots that beginners and students would get their first robotic experience with. In this project, we have
designed a simple Line Follower Robot using Arduino and some other components.
Arduino Line Follower Robot
Image 4
Arduino Line Follower Robot
path
Arduino Line Follower Robot
1
Arduino Line Follower Robot
2
Arduino Line Follower Robot
Image 3
Arduino Line Follower Robot
Image 4
Arduino Line Follower Robot
path

Table of Contents

 Circuit Diagram
 Components Required
 Block Diagram of the Project
o Block Diagram Description
 Working of Arduino Line Follower Robot
 Code
 Applications of Line Follower Robot
 Construction and Output Video

Circuit Diagram

Components Required

 Arduino UNO (or Arduino Nano)


 L293D Motor Driver IC
 Geared Motors x 2
 Robot Chassis
 IR Sensor Module x 2
 Black Tape (Electrical Insulation Tape)
 Connecting Wires
 Power supply

Note: We have used a prebuilt IR Sensor Module that consists of an IR LED and a Photo Diode. If you do not have this, we have explained how
to build one yourself.

Block Diagram of the Project

The line follower robot built in this project is divided in to 4 blocks. The following image shows the block diagram for line follower robot.

Block Diagram Description

Sensors (IR Sensor): We have used IR Sensor Module as the line detecting sensor for the project. It consists of an IR LED and a Photo diode
and some other components like comparator, LED etc.
As mentioned earlier, we have used a pre – assembled IR Sensor. In case you do not have one, you can make your own sensor using the
following circuit.
The working of the IR Sensor and its scope in this project will be explained in the actual working of the Line Follower Robot.

Controller (Arduino UNO): Arduino UNO is the main controller in the project. The data from the sensors (IR Sensors) will be given to Arduino
and it gives corresponding signals to the Motor Driver IC.

Motor Driver (L293D): L293D Motor Driver IC is used in this project to drive the motors of the robot. It receives signals from Arduino based
on the information from the IR Sensors.

Note: The power supply to the motors must be given from the motor driver IC. Hence, choose the appropriate power supply which is sufficient
for all the components including the motors.
Motors (Geared Motors): We have used two geared motors at the rear of the line follower robot. These motors provide more torque than normal
motors and can be used for carrying some load as well.

Working of Arduino Line Follower Robot

In this project, we have designed an Arduino based Line Follower Robot. The working of the project is pretty simple: detect the black line on the
surface and move along that line. The detailed working is explained here.

As mentioned in the block diagram, we need sensors to detect the line. For line detection logic, we used two IR Sensors, which consists of IR
LED and Photodiode. They are placed in a reflective way i.e. side – by – side so that whenever they come in to proximity of a reflective surface,
the light emitted by IR LED will be detected by Photo diode.
The following image shows the working of a typical IR Sensor (IR LED – Photodiode pair) in front of a light coloured surface and a black
surface. As the reflectance of the light coloured surface is high, the infrared light emitted by IR LED will be maximum reflected and will be
detected by the Photodiode.

In case of black surface, which has a low reflectance, the light gets completely absorbed by the black surface and doesn‟t reach the photodiode.
Using the same principle, we will setup the IR Sensors on the Line Follower Robot such that the two IR Sensors are on the either side of the
black line on the floor. The setup is shown below.
When the robot moves forward, both the sensors wait for the line to be detected. For example, if the IR Sensor 1 in the above image detects the
black line, it means that there is a right curve (or turn) ahead.

Arduino UNO detects this change and sends signal to motor driver accordingly. In order to turn right, the motor on the right side of the robot is
slowed down using PWM, while the motor on the left side is run at normal speed.

Similarly, when the IR Sensor 2 detects the black line first, it means that there is a left curve ahead and the robot has to turn left. For the robot to
turn left, the motor on the left side of the robot is slowed down (or can be stopped completely or can be rotated in opposite direction) and the
motor on the right side is run at normal speed.
Arduino UNO continuously monitors the data from both the sensors and turns the robot as per the line detected by them.

Code

int mot1=9;

int mot2=6;

int mot3=5;

int mot4=3;

int left=13;

int right=12;

int Left=0;

int Right=0;

void LEFT (void);

void RIGHT (void);

void STOP (void);


void setup()

pinMode(mot1,OUTPUT);

pinMode(mot2,OUTPUT);

pinMode(mot3,OUTPUT);

pinMode(mot4,OUTPUT);

pinMode(left,INPUT);

pinMode(right,INPUT);

digitalWrite(left,HIGH);

digitalWrite(right,HIGH);

void loop()

{
analogWrite(mot1,255);

analogWrite(mot2,0);

analogWrite(mot3,255);

analogWrite(mot4,0);

while(1)

Left=digitalRead(left);

Right=digitalRead(right);

if((Left==0 && Right==1)==1)

LEFT();

else if((Right==0 && Left==1)==1)

RIGHT();

}
}

void LEFT (void)

analogWrite(mot3,0);

analogWrite(mot4,30);

while(Left==0)

Left=digitalRead(left);

Right=digitalRead(right);

if(Right==0)

int lprev=Left;

int rprev=Right;
STOP();

while(((lprev==Left)&&(rprev==Right))==1)

Left=digitalRead(left);

Right=digitalRead(right);

analogWrite(mot1,255);

analogWrite(mot2,0);

analogWrite(mot3,255);

analogWrite(mot4,0);

void RIGHT (void)


{

analogWrite(mot1,0);

analogWrite(mot2,30);

while(Right==0)

Left=digitalRead(left);

Right=digitalRead(right);

if(Left==0)

int lprev=Left;

int rprev=Right;

STOP();

while(((lprev==Left)&&(rprev==Right))==1)
{

Left=digitalRead(left);

Right=digitalRead(right);

analogWrite(mot3,255);

analogWrite(mot4,0);

analogWrite(mot1,255);

analogWrite(mot2,0);

void STOP (void)

analogWrite(mot1,0);
analogWrite(mot2,0);

analogWrite(mot3,0);

analogWrite(mot4,0);

view raw Arduino Line follower robot hosted with by GitHub

Note:

 In order to increase the efficiency of black line detection, number of sensors can be increased. An array of sensors will be more accurate than just
two sensors.
 In this project (where two sensors are used), the positioning of the sensors is very important. The width of the black line plays a major role in the
placement of the sensors.
 The sensor to detect the line can also be constructed using an LED and LDR pair.

Applications of Line Follower Robot

 Line follower Robots are commonly used for automation process in industries, military applications and consumer applications.
 They are very useful as they can work without any supervision i.e. they work as automatic guided vehicles.
 With additional features like obstacle avoidance and other security measures, line follower robots can be used in driver less cars.

Construction and Output Video

This is the starter kit that has come into the existence when a motion of the robot is given high priority. It follows the visual line path and some
advanced line follower robots uses an invisible magnetic field as their paths.
As you are aware of robot applications in military, industries and domestic purposes that are in great demand. We offered the Arduino Robot
Kits that satisfies all your desires. Have a look at these Arduino robot kits that has a wide range of applications and comes at very low prices.

If you have any doubts, please share with us in the comment section given below. We are very happy to respond quickly

3.2 alarm sensor


[Link]
alarm-with-an-arduino-and-ir-sensors/
Create a Motion-Sensing Alarm with an Arduino and IR Sensors
June 02, 2015 by Tim Youngblood

Infrared (IR) sensors are normally used to measure distances, but they can also be used to detect objects. By connecting a couple of IR sensors to an
Arduino, you can make an intruder alarm.

Overview

Infrared (IR) sensors are normally used to estimate the distance of an object, but you can also use them to detect the presence of objects. IR
sensors consist of an IR transmitter and and IR receiver. The transmitter outputs pulses of infrared radiation, while at the same time, the receiver
detects any reflections. If the receiver does detect a reflection, it means that there is an object at some distance in front of the sensor. If there is no
reflection, then there is no object.

The IR sensor that we are using in this project is a sharp infrared IR ranger. These sensors have a small linear charge-coupled device (CCD) array
that detects the angle at which the IR radiation returns to the sensor. As shown in the figure below, the sensor transmits an infrared pulse into the
field, and when there is an object in front of the sensor, the pulse is reflected back to the sensor at an angle proportional to the distance that the
object is away from the sensor. The sensor's receiver detects and outputs the angle, and using this value, you can calculate the distance.
By connecting a couple of IR sensors to an Arduino, we can make a simple intruder alarm. We will connect the sensors to a door jamb, and by
properly aligning the sensors, we can detect when someone passes through the door. When this happens, the output of the IR sensor will change,
and we will detect this change by continually reading the output of the IR sensors with an Arduino. In this example, we know that an object is
passing through the door when the IR sensor‟s output exceeds 400. When this occurs, the Arduino will set the alarm to ON. To reset the alarm, a
user can press a pushbutton.

Hardware Required

 2 x long-range IR sensors
 1 x Arduino Mega2560
 1 x buzzer
 1 x pushbutton
 1 x 470 ohm resistor
 1 x NPN transistor
 jumper wires

Wiring Diagram

The circuit for this project is shown in the diagram below. The outputs of the two IR sensors connect to A0 and A1. The other two wires are
connected to 5V and GND. A 12V buzzer is connected to pin 3 through a transistor and the pushbutton used to shut the alarm OFF connects to
pin 4.
The photo below shows how we taped the sensors to the door jamb for this experiment. You would, of course, install the sensors much
differently for a more permanent installation.
Setup:

1. Connect Arduino 5V and GND pins the +5V and ground terminals of the sensors. You can also supply voltage to them externally.
2. Connect the sensor output terminals to the Arduino A0 and A1 pins.
3. Connect Arduino pin 3 to the base of the transistor through a 1K resister.
4. Apply 12V to collector of transistor.
5. Connect positive terminal of 12V buzzer to emitter and negative to ground.
6. Connect Arduino pin 4 to 5V through a push button. Its always better to connect a small resistor with it to be on a safe side to avoid flow of
excessive current.
7. Connect the Arduino using Arduino USB cable and upload the program to Arduino using Arduino IDE software.
8. Provide power to the Arduino board using power supply, battery or USB cable.

Code

const int buzzer=3; // pin 3 is the buzzer output


const int pushbutton=4; // pin 4 is the pushbutton input

void setup()
{
pinMode(buzzer,OUTPUT); //configure pin 4 as OUTPUT
pinMode(pushbutton,INPUT); //configure pin 4 as INPUT
}
void loop()
{
int sensor1_value=analogRead(A0); //read the output of both sensors and compare to the threshold value
int sensor2_value=analogRead(A1);
if (sensor1_value>400||sensor2_value>400)
{
while(true)
{
digitalWrite(buzzer,HIGH); //sets the alarm ON
if(digitalRead(pushbutton)==HIGH)
break;
}
}
else
digitalWrite(buzzer,LOW); //turn off alarm
}
[Link]
[Link]
ultrasonic-sensor
1. projet porte ouverte
Use an Arduino and an ultrasonic sensor to make a door alarm that sounds when someone comes within a certain distance.





1 Arduino Uno
1 HC-SR04 ultrasonic sensor
1 Buzzer
Connecting wires
1 Breadboard

In this project, we are going to make a door alarm system using the HC-SR04 ultrasonic sensor. The ultrasonic sensor used in this project is used
as a distance sensor, it will tell us the distance at which the object is placed. Using this distance value, we will turn the buzzer on or off.
Circuit Diagram

The hardware part of this project is very easy to put together. First of all, make the connections for the ultrasonic sensor with the Arduino. The
connections for the ultrasonic sensor with the Arduino are as follows:
 Connect VCC on the ultrasonic sensor to the 5V pin on the Arduino.
 Connect the Trig pin on the ultrasonic sensor to pin 2 on the Arduino.
 Connect the Echo pin on the ultrasonic sensor to pin 3 on the Arduino.
 Connect the GND on the ultrasonic sensor to GND on the Arduino.

After that, make the connections for the buzzer and the Arduino. Connect the positive pin on the buzzer with pin 10 on the Arduino and the
buzzer's negative pin with the GND pin on the Arduino.
How Does the Arduino Door Alarm Work?

The ultrasonic sensor emits an ultrasonic wave from the trigger which comes back after hitting the object and it is received by the echo. The echo
will then tell us the distance traveled in microseconds. To send an ultrasonic wave from the trigger, we will have to set the trigger high for 10us.
This will send an 8 cycle sonic burst at 40 kHz which will hit the object and is then received by the echo.

We have got the time in microseconds but we need to calculate the distance. So, we will use the equation below.

S=v*t

We have the value of t and we know that the speed of a sound wave is 340m/s. We have to convert the speed of sound into cm/us to calculate the
distance. The speed of sound in cm/us is 0.034cm/us. The equation now will become ...

S = (0.034 * t)

We will divide this equation by 2 because we only require the distance it takes to hit the object and not the distance it takes to hit the object and
come back. So, the final equation will be

S = (0.035 * t)/2

We will get the distance value using the equation above and after that, we will set a value which will help us make the buzzer high or low.

Code
int trigger_pin = 2;

int echo_pin = 3;

int buzzer_pin = 10;

int time;

int distance;
void setup ( ) {

[Link] (9600);

pinMode (trigger_pin, OUTPUT);

pinMode (echo_pin, INPUT);

pinMode (buzzer_pin, OUTPUT);

void loop ( ) {

digitalWrite (trigger_pin, HIGH);

delayMicroseconds (10);

digitalWrite (trigger_pin, LOW);

time = pulseIn (echo_pin, HIGH);

distance = (time * 0.034) / 2;

if (distance <= 10)

[Link] (" Door Open ");


[Link] (" Distance= ");

[Link] (distance);

digitalWrite (buzzer_pin, HIGH);

delay (500);

else {

[Link] (" Door closed ");

[Link] (" Distance= ");

[Link] (distance);

digitalWrite (buzzer_pin, LOW);

delay (500);

Code Explanation

First of all, we initialized the trigger pin and echo for the ultrasonic sensor. We have connected the trigger pin to pin 2 on the Arduino and echo
pin to pin 3 on the Arduino. Therefore, we initialized these pins in the code. Then we initialized the buzzer pin and after that, we initialized the
variable which will help us in calculating the distance.
int trigger_pin = 2;

int echo_pin = 3;

int buzzer_pin = 10;

int time;
int distance;

In the setup function, we declare the trigger pin as the output pin because we will send the ultrasonic wave through that pin. We made the echo
pin as input pin because we will receive the ultrasonic wave through the echo.

pinMode (trigger_pin, OUTPUT);

pinMode (echo_pin, INPUT);

In the loop function, we set the trigger pin high for 10 us to send an ultrasonic wave and then we made the echo pin high to receive the ultrasonic
wave. After that, we applied the equation to get the distance value.

digitalWrite (trigger_pin, HIGH);

delayMicroseconds (10);

digitalWrite (trigger_pin, LOW);

time = pulseIn (echo_pin, HIGH);

distance = (time * 0.034) / 2;

Then we made a condition that if the distance value is less than or equal to 10, then the buzzer will start to beep. If the distance value is greater
than 10, then the buzzer will remain quiet.

if (distance <= 10)

[Link] (" Door Open ");

[Link] (" Distance= ");

[Link] (distance);

digitalWrite (buzzer_pin, HIGH);


delay (500);

[Link] mesurer distance


[Link]

How It Works – Ultrasonic Sensor

It emits an ultrasound at 40 000 Hz which travels through the air and if there is an object or obstacle on its path It will bounce back to the
module. Considering the travel time and the speed of the sound you can calculate the distance.
The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The Ground and the VCC pins of the module needs to be connected
to the Ground and the 5 volts pins on the Arduino Board respectively and the trig and echo pins to any Digital I/O pin on the Arduino Board.

In order to generate the ultrasound you need to set the Trig on a High State for 10 µs. That will send out an 8 cycle sonic burst which will travel
at the speed sound and it will be received in the Echo pin. The Echo pin will output the time in microseconds the sound wave traveled.
For example, if the object is 10 cm away from the sensor, and the speed of the sound is 340 m/s or 0.034 cm/µs the sound wave will need to
travel about 294 u seconds. But what you will get from the Echo pin will be double that number because the sound wave needs to travel forward
and bounce backward. So in order to get the distance in cm we need to multiply the received travel time value from the echo pin by 0.034 and
divide it by 2.
Components needed for this tutorial

You can get these components from any of the sites below:

 Ultrasonic Sensor HC-SR04……… Amazon / Aliexpress


 Arduino Board…………………………. Amazon / Aliexpress
 Breadboard and Jump Wires……. Amazon / Aliexpress

*Please note: These are affiliate links. I may make a commission if you buy the components through these links.
I would appreciate your support in this way!

Source Codes
First you have to define the Trig and Echo pins. In this case they are the pins number 9 and 10 on the Arduino Board and they are named trigPin
and echoPin. Then you need a Long variable, named “duration” for the travel time that you will get from the sensor and an integer variable for
the distance.

In the setup you have to define the trigPin as an output and the echoPin as an Input and also start the serial communication for showing the
results on the serial monitor.

In the loop first you have to make sure that the trigPin is clear so you have to set that pin on a LOW State for just 2 µs. Now for generating the
Ultra sound wave we have to set the trigPin on HIGH State for 10 µs. Using the pulseIn() function you have to read the travel time and put that
value into the variable “duration”. This function has 2 parameters, the first one is the name of the echo pin and for the second one you can write
either HIGH or LOW. In this case, HIGH means that the pulsIn() function will wait for the pin to go HIGH caused by the bounced sound wave
and it will start timing, then it will wait for the pin to go LOW when the sound wave will end which will stop the timing. At the end the function
will return the length of the pulse in microseconds. For getting the distance we will multiply the duration by 0.034 and divide it by 2 as we
explained this equation previously. At the end we will print the value of the distance on the Serial Monitor.

1. /*
2. * Ultrasonic Sensor HC-SR04 and Arduino Tutorial
3. *
4. * Crated by Dejan Nedelkovski,
5. * [Link]
6. *
7. */
8.
9. // defines pins numbers
10. const int trigPin = 9;
11. const int echoPin = 10;
12.
13. // defines variables
14. long duration;
15. int distance;
16.
17. void setup() {
18. pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
19. pinMode(echoPin, INPUT); // Sets the echoPin as an Input
20. [Link](9600); // Starts the serial communication
21. }
22.
23. void loop() {
24. // Clears the trigPin
25. digitalWrite(trigPin, LOW);
26. delayMicroseconds(2);
27.
28. // Sets the trigPin on HIGH state for 10 micro seconds
29. digitalWrite(trigPin, HIGH);
30. delayMicroseconds(10);
31. digitalWrite(trigPin, LOW);
32.
33. // Reads the echoPin, returns the sound wave travel time in microseconds
34. duration = pulseIn(echoPin, HIGH);
35.
36. // Calculating the distance
37. distance= duration*0.034/2;
38.
39. // Prints the distance on the Serial Monitor
40. [Link]("Distance: ");
41. [Link](distance);
42. }

[Link] mesurer distance avec lcd


[Link]

f you want to display the results from the HC-SR04 Ultrasonic Sensor on an LCD you can use the following source code:

1. /*
2. * Ultrasonic Sensor HC-SR04 and Arduino Tutorial
3. *
4. * Crated by Dejan Nedelkovski,
5. * [Link]
6. *
7. */
8.
9. #include <LiquidCrystal.h> // includes the LiquidCrystal Library
10.
11. LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)
12.
13. const int trigPin = 9;
14. const int echoPin = 10;
15.
16. long duration;
17. int distanceCm, distanceInch;
18.
19. void setup() {
20. [Link](16,2); // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display
21.
22. pinMode(trigPin, OUTPUT);
23. pinMode(echoPin, INPUT);
24. }
25.
26. void loop() {
27. digitalWrite(trigPin, LOW);
28. delayMicroseconds(2);
29.
30. digitalWrite(trigPin, HIGH);
31. delayMicroseconds(10);
32. digitalWrite(trigPin, LOW);
33.
34. duration = pulseIn(echoPin, HIGH);
35. distanceCm= duration*0.034/2;
36. distanceInch = duration*0.0133/2;
37.
38. [Link](0,0); // Sets the location at which subsequent text written to the LCD will be displayed
39. [Link]("Distance: "); // Prints string "Distance" on the LCD
40. [Link](distanceCm); // Prints the distance value from the sensor
41. [Link](" cm");
42. delay(10);
43. [Link](0,1);
44. [Link]("Distance: ");
45. [Link](distanceInch);
46. [Link](" inch");
47. delay(10);
48. }

Feel free to ask any question in the comments section below and don‟t forget to check out my collection of Arduino Projects.

Dernier projet
[Link]

Ce stick Smart aura un capteur à ultrasons pour détecter la distance de tout obstacle, LDR pour détecter les
conditions d'éclairage et une télécommande RF permettant à l'aveugle de localiser son stick à distance.
Tous les retours seront donnés à l'aveugle à travers un Buzzer. Bien sûr, vous pouvez utiliser un moteur de
vibrateur à la place de Buzzer et avancer beaucoup plus en utilisant votre créativité

Ever heard of Hugh Herr? He is a famous American rock climber who has shattered the limitations of his disabilities; he is a strong believer that
technology could help disabled persons to live a normal life. In one of his TED talk Herr said “Humans are not disabled. A person can never be
broken. Our built environment, our technologies, is broken and disabled. We the people need not accept our limitations, but can transfer
disability through technological Innovation”. These were not just words but he lived his life to them, today he uses Prosthetic legs and claims to
live to normal life. So yes, technology can indeed neutralize human disability; with this in mind let us use the power of Arduino and simple
sensors to build a Blind man’s stick that could perform more than just a stick for visually impaired persons.

This Smart stick will have an Ultrasonic sensor to sense distance from any obstacle, LDR to sense lighting conditions and a RF remote
using which the blind man could remotely locate his stick. All the feedbacks will be given to the blind man through a Buzzer. Of course you
can use a vibrator motor in place of Buzzer and advance a lot more using your creativity.

Materials Required:
1. Arduino Nano (Any version will work)
2. Ultrasonic Sensor HC-SR04
3. LDR
4. Buzzer and LED
5. 7805
6. 433MHz RF transmitter and receiver
7. Resistors
8. Push button
9. Perf board
10. Soldering Kit
11. 9V batteries

Circuit Diagram:

This Arduino Smart Blind Stick Project requires two separate circuits. One is the main circuit which will be mounted on the blind man‟s stick.
The other is a small remote RF transmitter circuit which will be used to locate the main circuit. The main board‟s circuit diagram is shown
below:

Ce projet Arduino Smart Blind Stick nécessite deux circuits distincts. L'un est le circuit principal
qui sera monté sur le bâton de l'aveugle. L'autre est un petit circuit d'émetteur RF à distance
qui sera utilisé pour localiser le circuit principal. Le schéma du circuit de la carte principale est
illustré ci-dessous:
As we can see an Arduino Nano is used to control all the sensors. The complete board is powered by a 9V battery which is regulated to +5V
using a 7805 Voltage regulator. The Ultrasonic sensor is powered by 5V and the trigger and Echo pin is connected to Arduino nano pin 3 and 2
as shown above. The LDR is connected with a resistor of value 10K to form a Potential divider and the difference in voltage is read by Arduino
ADC pin A1. The ADC pin A0 is used to read the signal from RF receiver. The output of the board is given by the Buzzer which is connected to
pin 12.

The RF remote circuit is shown below. Its working is also further explained.
I have used a small hack to make this RF remote control circuit to work. Normally while using this 433 MHz module requires an Encoder and
Decoder or two MCU to work. But, in our application we just need the receiver to detect if the transmitter is sending some signals. So the Data
pin of the transmitter is connected to Ground or Vcc of the supply.

The data pin of the receiver is passed through an RC filter and then given to the Arduino as shown below. Now, whenever the button is pressed
the Receiver output some constant ADC value repeatedly. This repetition cannot be observed when the button is not pressed. So we write the
Arduino program to check for repeated values to detect if the button is pressed. So that is how a Blind person can track his stick. You can check
here: how RF transmitter and receiver work.

I have used a perf board to solder all the connections so that it gets intact with the stick. But, you can also make them on a breadboard. The
boards that I made are below.
Arduino Program for Smart Blind Stick:

Once we are ready with our hardware, we can connect the Arduino to our Computer and start programming. The complete code used for this
page can be found at the bottom of this page, you can upload it directly to your Arduino board. However, if you are curious to know how the
code works read further.

Like all programs we start with void setup() to initialise Input Output pins. In our program the Buzzer and Trigger pin is an Output device and
the Echo pin is an Input device. We also initialise the serial monitor for debugging.

void setup()
{
[Link](9600);
pinMode(Buzz,OUTPUT);
digitalWrite(Buzz,LOW);
pinMode(trigger, OUTPUT);
pinMode(echo, INPUT);
}

Inside the main loop we are reading all the sensors data. We begin with reading the sensor data of Ultrasonic sensor for distance, LDR for
light intensity and RF signal to check if the button is pressed. All these data is saved in a variable as shown below for future use.

calculate_distance(trigger,echo);
Signal = analogRead(Remote);
Intens = analogRead(Light);

We start with checking for the Remote signal. We use a variable called similar_count to check how many times the same values are being
repeated from the RF receiver. This repetition will occur only when the button is pressed. So we trigger the Remote pressed alarm if the count
exceeds a value of 100.
//Check if Remote is pressed
int temp = analogRead(Remote);
similar_count=0;
while (Signal==temp)
{
Signal = analogRead(Remote);
similar_count++;
}

//If remote pressed


if (similar_count<100)
{
[Link](similar_count); [Link]("Remote Pressed");
digitalWrite(Buzz,HIGH);delay(3000);digitalWrite(Buzz,LOW);
}

You can also check it on Serial Monitor on your computer:

Next we check for the intensity of light around the blind man. If the LDR gives a value of less than 200 it is assumed to be very dark and we
give him the warning through buzzer with a specific tone of delay with 200ms. If the intensity is very bright that is more than 800 then also we
give a warning with another tone. The alarm tone and intensity can be easily varied by changing the respective value in the below code.

//If very dark


if (Intens<200)
{
[Link](Intens); [Link]("Bright Light");

digitalWrite(Buzz,HIGH);delay(200);digitalWrite(Buzz,LOW);delay(200);digitalWrite(Buzz,HIGH);delay(200);digitalWrite
(Buzz,LOW);delay(200);
delay(500);
}

//If very bright


if (Intens>800)
{
[Link](Intens); [Link]("Low Light");

digitalWrite(Buzz,HIGH);delay(500);digitalWrite(Buzz,LOW);delay(500);digitalWrite(Buzz,HIGH);delay(500);digitalWrite
(Buzz,LOW);delay(500);
}

Finally, we start measuring the distance from any obstacle. There will be no alarm if the measured distance is more than 50cm. But, if it is less
than 50cm the alarm will start by beeping the buzzer. As the object gets closer to the buzzer the beeping interval will also decrease. The
closer the object is the faster the buzzer will beep. This can be done by creating a delay that is proportional to the distance measured. Since the
delay () in Arduino cannot accept variables we have to use a for loop which loop based on the measured distance as shown below.

if (dist<50)
{
[Link](dist); [Link]("Object Alert");
digitalWrite(Buzz,HIGH);
for (int i=dist; i>0; i--)
delay(10);
digitalWrite(Buzz,LOW);
for (int i=dist; i>0; i--)
delay(10);
}

Learn more about measuring the distance using Ultrasonic sensor and Arduino.

The program can be easily adapted for your application by changing the value which we use to compare. You use the serial monitor to debug if a
false alarm is trigger. If you have any problem you can use the comment section below to post your questions

Arduino Blind Stick in Action:

Finally it‟s time to test our project. Make sure the connections are done as per the circuit diagram and the program is successfully uploaded.
Now, power both the circuits using a 9V battery and you should start to see results. Move the Ultra Sonic sensor closer to object and you will
notice the Buzzer beeping and this beeping frequency increases as the stick goes closer to object. If the LDR is covered in dark or if there is
too much light the buzzer will beep. If everything is normal the buzzer will not beep.

When you press the button on the remote the buzzer will give a long beep. The complete working of this Smart Blind Stick is shown in the
Video given at the end of this page. I also use a small stick to mount the complete assembly you can use a larger one or an actual blind stick and
put it in action.
If your buzzer is always beeping it means the alarm is being false triggered. You can open the serial monitor to check for the parameters and
check which is falling in critical and adjust that. As always you can post your problem in the comment section to get help. Hope you understood
the project and enjoyed building something.

Code:

/*
* Program for Blind Man Stick
* Code by [Link] Raj
* Dated: 03-11-2017
* Website: [Link]
*/

const int trigger = 3; //Trigger pin of 1st Sesnor


const int echo = 2; //Echo pin of 1st Sesnor
const int Buzz = 13; //Echo pin of 1st Sesnor
const int Remote = A0; //Echo pin of 1st Sesnor
const int Light = A1; //Echo pin of 1st Sesnor

long time_taken;
int dist;
int Signal;
int Intens;
int similar_count;

void setup() {
[Link](9600);
pinMode(Buzz,OUTPUT);
digitalWrite(Buzz,LOW);
pinMode(trigger, OUTPUT);
pinMode(echo, INPUT);

}
/*###Function to calculate distance###*/
void calculate_distance(int trigger, int echo)
{
digitalWrite(trigger, LOW);
delayMicroseconds(2);
digitalWrite(trigger, HIGH);
delayMicroseconds(10);
digitalWrite(trigger, LOW);

time_taken = pulseIn(echo, HIGH);


dist= time_taken*0.034/2;
if (dist>300)
dist=300;
}

void loop() { //infinite loopy


calculate_distance(trigger,echo);
Signal = analogRead(Remote);
Intens = analogRead(Light);

//Check if Remote is pressed


int temp = analogRead(Remote);
similar_count=0;
while (Signal==temp)
{
Signal = analogRead(Remote);
similar_count++;
}

//If remote pressed


if (similar_count<100)
{
[Link](similar_count); [Link]("Remote Pressed");
digitalWrite(Buzz,HIGH);delay(3000);digitalWrite(Buzz,LOW);
}

//If very dark


if (Intens<200)
{
[Link](Intens); [Link]("Bright Light");
digitalWrite(Buzz,HIGH);delay(200);digitalWrite(Buzz,LOW);delay(200);digitalWrite(Buzz,HIGH);delay(200);

digitalWrite(Buzz,LOW);delay(200);
delay(500);
}

//If very bright


if (Intens>800)
{
[Link](Intens); [Link]("Low Light");
digitalWrite(Buzz,HIGH);delay(500);digitalWrite(Buzz,LOW);delay(500);digitalWrite(Buzz,HIGH);delay(500);

digitalWrite(Buzz,LOW);delay(500);
}

if (dist<50)
{
[Link](dist); [Link]("Object Alert");

digitalWrite(Buzz,HIGH);
for (int i=dist; i>0; i--)
delay(10);

digitalWrite(Buzz,LOW);
for (int i=dist; i>0; i--)
delay(10);
}

//[Link]("dist=");
//[Link](dist);
//[Link]("Similar_count=");
//[Link](similar_count);
//[Link]("Intens=");
//[Link](Intens);
}

1. pir HC-SR501
[Link]
works-and-how-to-use-it-with-arduino/
In this Arduino Tutorial we will learn how a PIR Sensor works and how to use it with the Arduino Board for detecting motion. You can watch
the following video or read the written tutorial below.

How It Works

First let‟s explain the working principle. The module actually consists of a Pyroelectric sensor which generates energy when exposed to heat.
That means when a human or animal body will get in the range of the sensor it will detect a movement because the human or animal body emits
heat energy in a form of infrared radiation. That‟s where the name of the sensor comes from, a Passive Infra-Red sensor. And the term “passive”
means that sensor is not using any energy for detecting purposes, it just works by detecting the energy given off by the other objects.
The module also consists a specially designed cover named Fresnel lens, which focuses the infrared signals onto the pyroelectric sensor.
The HC-SR501 PIR Sensor Module

The module has just three pins, a Ground and a VCC for powering the module and an output pin which gives high logic level if an object is
detected. Also it has two potentiometers. One for adjusting the sensitivity of the sensor and the other for adjusting the time the output signal stays
high when object is detected. This time can be adjusted from 0.3 seconds up to 5 minutes.
The module has three more pins with a jumper between two of them. These pins are for selecting the trigger modes. The first one is called “non-
repeatable trigger” and works like this: when the sensor output is high and the delay time is over, the output will automatically change from high
to low level. The other mode called “repeatable trigger” will keep the output high all the time until the detected object is present in sensor‟s
range.

Components needed for this tutorial

You can get the components from any of the sites below:

 HC-SR501 PIR Sensor Module…….. Amazon / Aliexpress


 5V Relay Module………………………….. Amazon / Aliexpress
 Arduino Board……………………………… Amazon / Aliexpress
 Breadboard and Jump Wires…………. Amazon / Aliexpress
 Cable, Plug, Socket
*Please note: These are affiliate links. I may make a commission if you buy the components through these links.
I would appreciate your support in this way!

Circuit Schematic

As an example for this tutorial I will make a circuit that will turn on a high voltage lamp when the sensor will detect an object. Here‟s the circuit
schematics. The output pin of the sensor will be connected to pin number 8 on the Arduino Board and when an object will be detected the pin
number 7 will activate the relay module and the high voltage lamp will turn on.
For more details how the relay module works, you can check my Arduino Relay Tutorial. (Keep in minds that we use high voltage in the
example, so you should be very caution, because I don‟t take any responsibility of your actions)

Source Code

Here‟s the Arduino Code for this example. It‟s quite simple. We just need to define the PIR Sensor pin as input and the relay pin as output. Using
the digitalRead() function we will read the output of the sensor and if its high or if an object is detected it will activate the relay. For activating
the relay module we will send a logic low as the relay input pin works inversely.

1. /* Arduini PIR Motion Sensor Tutorial


2. *
3. * by Dejan Nedelkovski, [Link]
4. *
5. */
6. int pirSensor = 8;
7. int relayInput = 7;
8.
9. void setup() {
10. pinMode(pirSensor, INPUT);
11. pinMode(relayInput, OUTPUT);
12. }
13.
14. void loop() {
15. int sensorValue = digitalRead(pirSensor);
16.
17. if (sensorValue == 1) {
18. digitalWrite(relayInput, LOW); // The Relay Input works Inversly
19. }
20. }

The demonstration of the example can be seen at the end of the video attached above. Note that after powering the sensor module it needs about
20 – 60 seconds to “warm-up” in order to function properly. Now when you will put your hand in front of the sensor the relay will activate the
lamp. But note that even if you move your hand constantly the lamp will turn off after the adjusted delay time is over because the PIR sensor is in
“non-repeatable trigger” mode. If you change the sensor with the jumper to the “repeatable trigger” mode and you constantly move the hand, the
lamp will be constantly on as well and it will turn off after the movement is gone and the set delay time is over.

Lien pour construire des robots


[Link]
exemple1

[Link]
ed373f?ref=search&ref_id=gaz%20leakage%20robot&offset=5

exemple2

suiveur soleil simple

[Link]

[Link] this project

1. How does it Work?

The choice to go up or down in order to follow the light is done in a very simple way. There are four LDR two up and two down. Arduino reads
the analog value of all LDR, if the average of the two upper values is greater than the two lower the light is up so the angle of the microservo is
incremented otherwise decremented.
2. A Little Clarification

Since the average is not a fixed number, as you can see in the code, a threshold is used. In this way the angle is changed if and only if the two
averages are widely different.

const int threshold = 50;


[.....]
down_average = (A0_val + A1_val)/2;
up_average = (A2_val + A3_val)/2;
diff = abs(up_average-down_average);
if ((up_average > down_average) && (diff > threshold))
{
if (val < 180) //if different from max val
{
val++;
[Link](val);
}
}
if((down_average > up_average) && (diff > threshold))
{
if (val > 0) //if different from min val
{
val--;
[Link](val);
}
}

3. The Circuit

Make the circuit below!

4. Print & Cut

Download the attached file, print it, glue it on the cardboard and cut all the pieces for yours light follower. You should obtain something like
this.

5. Mount the Base


Mount the breadboard base in this way. Glue it if necessary.

6. Mount the Servo

Mount the servo like below. Screw it for more stability.

7. Mount the Bracket

Mount the bracket in this way.

8. Mount the Servo Gear

Mount the servo gear. Screw it in this way.

9. Put all Together

Put all together. You should obtain something like this

10. Glue the Breadboard on the Base

Glue the breadboard on the base. You can use the biadhesive tape of the breadboard.

11. Screw Arduino

Screw Arduino on the back of the base.

12. Well Done

Well done. Now you have all the necessary. Download the code on your Arduino and enjoy with your light follower!
Code
Light Follower codeArduino
/*
A simple light follower
author: Arturo Guadalupi <[Link]@[Link]>
*/
#include <Servo.h>
Servo myservo;
int up_average;
int down_average;
int A0_val;
int A1_val;
int A2_val;
int A3_val;
int val = 90;
int diff;
const int threshold = 50;
void setup() {
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
[Link](11);
[Link](val);
}
void loop() {
A0_val = analogRead(A0); //reading data from sensors
A1_val = analogRead(A1);
A2_val = analogRead(A2);
A3_val = analogRead(A3);

down_average = (A0_val + A1_val)/2; //the sum of the two lower sensors /2


up_average = (A2_val + A3_val)/2; //the sum of the two upper sensors /2
diff = abs(up_average-down_average); //checking the difference between the two averages
if ((up_average > down_average) && (diff > threshold))
{
if (val < 180) //if different from max val
{
val++;
[Link](val);
}
}
if((down_average > up_average) && (diff > threshold))
{
if (val > 0) //if different from min val
{
val--;
[Link](val);
}
}
delay(25);
}

Custom parts and enclosures


LightFollower DXF
[Link]
Schematics
Layout
2.

out this project

If you're a beginner in Arduino and have a plan to make your first robot, then here's the tutorial for you. Look at the images of what you are
going to build, today.

In this tutorial I am going to show how to make an Arduino robot with different functionalities. We can learn the use of different programs for
different functions, mainly a smart phone controlled robot with Obstacle avoider, wall follower, and maze solver. Or you can also make it for
only a single function.

see it in action

Autonomous Function

Materials and Tools

Step 2: Making the Chassis

Drill two holes for motor:

Connect two motors:

Make three holes for caster wheel:

Connect the caster wheel:

Make two holes on either side of the box for connecting the motors and three holes on the bottom for connecting the caster wheel after measuring
and marking the correct diameter. Then install the motors and the caster.

Batteries

Connecting the batteries.


Connection diagram.

Glue the batteries inside the box.

Mount two 9 volt batteries inside the box above the caster. Then wire them in parallel and connect a switch as shown in above diagram.

Connecting the Arduino and Motor Shield

Attach the motor shield above the Arduino.

Connect the battery wires to the PWR terminals of motor shield.

Connect the motors to the motor shield.

Remove the jumper from this port.

Connect the motor shield above the Arduino and place it above the battery. Then connect the wires from the motors and battery to the motor
shield. Check out the connection diagram before connecting, as it is very important.

Wiring Instructions:

 Connect the left motor to "M1" of motor shield

 Connect the right motor to "M3" of motor shield

 Connect the the wire from battery to "ext pwr" of motor shield

Don't forget to remove the jumper from the "pwr" of motor shield

Make two holes and power the Arduino

Mark the spot to make holes.


Make the holes.

Connect the battery clip to DC male jack to the 9V battery.

Place this 9 volt battery inside the box.

Make two holes for accessing the USB port and the DC input port of the Arduino. Take another 9 volt battery and connect a battery clip to a DC
male jack adapter, then connect the DC male jack to the Arduino DC input port, to power the Arduino. Then place the battery between the motors
and Arduino inside the box.

Connecting Bluetooth Module and Switch

Connect the Bluetooth module to the Arduino as shown in the connection diagram and place it inside the box. Then make hole to mount the
switch on the back side of the box and connect the switch (here I have changed the switch which is used earlier because of some soldering
problem).

Wiring Instruction of Bluetooth module:

 "TX" of Bluetooth Module goes to "RX" of Arduino

 "RX" of Bluetooth Module goes to "TX" of Arduino

 "VCC" of Bluetooth Module goes to "5v" of Arduino

 "GND" of Bluetooth Module goes to "GND" of Arduino

 The State & Key pins of the BT modules are kept unused.

Overall Circuit diagram

Sensor Ultrasonic Mounting


Take the ultrasonic sensor and glue a small 'L' shaped plastic piece to it and glue it on top of the plastic box (or if you don't have a glue stick use
double sided tape). Then connect the jumper wires to as shown in the circuit diagram above.

Wiring Instruction of ultrasonic sensor:

 "VCC" of Ultra sonic sensor goes to "+5" of Arduino

 "GND" of Ultra sonic sensor goes to "GND" of Arduino

 "Trig" pin of Ultra sonic sensor goes to "Analog pin 1" of Arduino

 "Echo" pin of Ultra sonic sensor goes to "Analog pin 0" of Arduino

Now we finished the all the connections and it's time to program.

Last step - Arduino codes and Bluetooth app editing

Upload the "Final Sketch" provided in the code section. If you face any error, make sure you have installed the AFmotor library.

Now, we learned how to program a Arduino easily. I have shown here some programs to work this robot as a obstacle avoiding robot, Wall
follower, and Bluetooth controlled. and at last i have combined this three functions together. Watch the video for more details and information

Make sure to install AFmotor library into Arduino. Download AFmotor library. To install Arduino library, refer this Page.

Getting Started with Bluetooth App

Some fun with Wall Follower & Obstacle Avoidance

Visit my blog here - [Link]

You might also like