Project tutorial
How to Make an IR Sensor

How to Make an IR Sensor © GPL3+

In this project, we will learn to build an IR sensor module with transistor and an Arduino as well.

  • 1,993 views
  • 0 comments
  • 10 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

About this project

Project Aim:

In this project, I'm going to build an IR sensor module using transistor, which can be used as an obstacle sensor and an Arduino to make a line following, obstacle avoiding module.

Reason for Project:

I was building an wifi robot which has three modes :

  • It can act as an line following robot
  • It can act as a WiFi controlled robot
  • It can act as an obstacle avoiding robot

Hence, to make line follower robot I needed line follower module and to make obstacle avoiding robot I needed ultrasonic sensor. But I did not have any of these so I thought of building my own line follower and obstacle sensor using ir leds. We can use an IR sensor module built into this project as an obstacle sensor instead of ultrasonic sensor.

In this project, you are going to learn how to build obstacle sensor using transistor (for those who doesn't know about arduino) and using an Arduino as well.

Code

Code for line follower module with arduinoC/C++
//Constants:
  
 int IRPin = 3; // declaring pin 3 to read digital input

//Variables:
int value; //save the digital value sent by ir led


void setup(){
  
  pinMode(IRPin, INPUT);  //Set pin 3 as 'input'
  Serial.begin(115200);       //Begin serial communication

}

void loop(){
  
  value = digitalRead(IRPin);         //Read and save digital value from ir sensor
  Serial.println(value);               //Print value
 
}
Code for obstcale avoiding module with arduinoC/C++
//Constants:
  
 int IRPin = A0; //pin A0 to read input

//Variables:
int value; //save analog value


void setup(){
  
  pinMode(IRPin, INPUT);// Set A0 as input
  Serial.begin(115200);       //Begin serial communication

}

void loop(){
  
  value = analogRead(IRPin);         //Read and save analog value from ir sensor
  Serial.println(value);               //Print value
 
}

Schematics

Connection of ir sensor with arduino
Circuit diagram of ir sensor with transistor
Tapscanner 20190703 172429 991 4lf3bffmgp

Comments

Similar projects you might like

Arduino-Based Automatic Water Tap Using IR Sensor

Project tutorial by Creatjet3D R&D Team

  • 9,310 views
  • 6 comments
  • 22 respects

Simple Obstacle Sensor with Arduino

Project tutorial by muhammed shameel k.v

  • 8,089 views
  • 2 comments
  • 11 respects

Ambient Light Sensor Using Photo Resistor and LED Lights!

Project tutorial by DCamino

  • 5,971 views
  • 5 comments
  • 21 respects

Touch Sensor and Sound Sensor Controlling AC/DC Lights

Project showcase by Anbumachi

  • 2,426 views
  • 2 comments
  • 7 respects
Add projectSign up / Login