Manikant savadatti
Published © GPL3+

How to Make an IR Sensor

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

BeginnerFull instructions provided30 minutes32,782
How to Make an IR Sensor

Things used in this project

Hardware components

IR transmitter (generic)
×1
IR receiver (generic)
×1
Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Resistor 100 ohm
Resistor 100 ohm
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
×1
Resistor 1k ohm
Resistor 1k ohm
×1
5 mm LED: Red
5 mm LED: Red
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Connection of ir sensor with arduino

Circuit diagram of ir sensor with transistor

Code

Code for line follower module with arduino

C/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 arduino

C/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
 
}

Credits

Manikant savadatti

Manikant savadatti

8 projects • 14 followers
I'm an Robotics Enthusiast and an Electronics and communication Engineering student studying in India .

Comments