Arduino infrared sensor

Help me by sharing this post


←PREVIOUS TUTORIAL       NEXT TUTORIAL→

See also original post. An IR sensor is an electronic instrument that scans IR signals in specific frequency ranges defined by standards and converts them to electric signals on its output pin (typically called signal pin). The IR signals are mainly used for transmitting commands over the air on short distances (typically few meters) like what you’ve already worked with on TV remote controls or other similar electronic devices..

Arduino IR sensor



PART 1 - Schematic

The connections are pretty easy, see the image below with the breadboard circuit schematic. The sensor will give an analog output or digital, according to the amount of IR light received. You could use this as a switch or sensor of light or fire.

We need:
1 x Arduino NANO/UNO: LINK eBay
1 x IR module: LINK eBay
1 x i2c LCD: LINK eBay
1 x Jump wires: LINK eBay
1 x Breadboard: LINK eBay

IR sensor arduino tutorial schematic




PART 2 - CODE results on serial monitor

We read the analog value from the sensor and print that to the serial monitor. You could make your own code and activate stuff, detect fire, etc...


Download serial monitor example code:


// IR sensor Test
// http://www.electronoobs.com/eng_arduino_tut74.php

int LED = 11; // Use the onboard Uno LED
int isObstaclePin = 7;  // This is our input pin
int isObstacle = HIGH;  // HIGH MEANS NO OBSTACLE

void setup() {  
  pinMode(LED, OUTPUT);
  pinMode(isObstaclePin, INPUT);
  Serial.begin(9600);
  
}

void loop() {
  int Value = analogRead(A0);  
  Serial.println("OBSTACLE!!, OBSTACLE!!");
  Serial.print("Analog read: ");Serial.println(Value);
  if(Value < 770)
  {
    digitalWrite(LED,HIGH);
  }
  else
  {
    digitalWrite(LED,LOW);
  }  
  delay(200);
}


Upload the code and make the connections. Then open the serial monitor at 9600 bauds and you will have the analog read printed to the serial monitor. Or go below and downlaod the code with the i2c LCD.





PART 3 - CODE results on LCD
Download LCD example code:
Download i2c LCD library:

// IR sensor Test
http://www.electronoobs.com/eng_arduino_tut72.php

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Set the LCD address to 0x27 or 0x3f for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 20, 4);

int LED = 11; // Use the onboard Uno LED
int isObstaclePin = 7;  // This is our input pin
int isObstacle = HIGH;  // HIGH MEANS NO OBSTACLE

void setup() {
  lcd.init();
  lcd.backlight();
  pinMode(LED, OUTPUT);
  pinMode(isObstaclePin, INPUT);
  Serial.begin(9600);
  
}

void loop() {
  int Value = analogRead(A0);  
  Serial.println("OBSTACLE!!, OBSTACLE!!");
  Serial.print("Analog read: ");Serial.println(Value);
  
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(" INFRARED LIGHT ");
  lcd.setCursor(5,1);
  lcd.print(Value);

  if(Value < 770)
  {
    digitalWrite(LED,HIGH);
  }
  else
  {
    digitalWrite(LED,LOW);
  }  
  delay(200);
}


Upload the code and make the connections. Then open the serial monitor at 9600 bauds or just see the results on the LCD screen.






←PREVIOUS TUTORIAL       NEXT TUTORIAL→

Help me by sharing this post








yt_link
insta_link
fb_link
twitter_link

Arduino infrared sensor
page 1/1



ADVERTISERS

WellPCB PCB Manufacturing
urPCB PCB Manufacturing
PCBGOGO PCB service

Gearbest Alfawise U30 2.8 inch Touch Screen DIY Desktop 3D Printer - U30 EU Plug Black
Alfawise U30 2.8 inch Touch Screen DIY Desktop 3D Printer - U30 EU Plug Black only $$162.89

AFFILATE

Gearbest Creality3D CR - 10S 3D Printer - EU Plug Upgrade Version Coffee and Black
Creality3D CR - 10S 3D Printer - EU Plug Upgrade Version Coffee and Black only $$352.94

Gearbest Creality 3D Ender-3 V-slot Prusa I3 DIY 3D Printer Kit 220 x 220 x 250mm Printing Size - EU Plug Black
Creality 3D Ender-3 V-slot Prusa I3 DIY 3D Printer Kit 220 x 220 x 250mm Printing Size - EU Plug Black only $$153.84

Gearbest Alfawise U20 Large Scale 2.8 inch Touch Screen DIY 3D Printer - EU - U20 EU Plug Black
Alfawise U20 Large Scale 2.8 inch Touch Screen DIY 3D Printer - EU - U20 EU Plug Black only $$253.39