Startertutorials Blog
Tutorials and articles related to programming, computer science, technology and others.
Subscribe to Startertutorials.com's YouTube channel for different tutorial and lecture videos.
Home » Computer Science » IoT Lab » Object Detection using IR Sensor and NodeMCU ESP8266
Suryateja Pericherla Categories: IoT Lab. 1 Comment on Object Detection using IR Sensor and NodeMCU ESP8266
3.8
(4)

In this article we will implement object detection using IR sensor and NodeMCU ESP8266. If your are new to Internet of Things (IoT), learn about IoT by visiting our Internet of Things tutorial for beginners.

 

Watch this video to learn about object detection using IR sensor and NodeMCU:

 

Aim of Experiment

To implement object detection using IR sensor.

 


Subscribe to our monthly newsletter. Get notified about latest articles, offers and contests.


Components Required

  • NodeMCU – 1
  • LED – 1
  • 330 Ω Resistor – 2
  • Active IR Sensor – 1
  • Active Buzzer – 1
  • Breadboard – 1

 

Connections Diagram (Schematic)

Object Detection using IR Sensor and NodeMCU ESP8266  

Code (C++/Arduino IDE)

//Set the pins for IR sensors, LED and Buzzer
const int IR_pin = D1;
const int LED_pin = D0;
const int Buzzer_pin = D3;
int value = 0;

void setup() {
  // put your setup code here, to run once:
  //Set the pin mode for IR sensor, LED and Buzzer
  pinMode(IR_pin, INPUT);
  pinMode(LED_pin, OUTPUT);
  pinMode(Buzzer_pin, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  //Read the value of IR sensor
  value = digitalRead(IR_pin);
  if(value == 1)
  {
    //Turn the LED on
    digitalWrite(LED_pin, HIGH);
    //Play the buzzer with 1KHz sound
    tone(Buzzer_pin, 1000);
  }
  else
  {
    //Turn off LED
    digitalWrite(LED_pin, LOW);
    //Turn off Buzzer
    noTone(Buzzer_pin);
  }
  delay(100);
}

 

How useful was this post?

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

1 Comment

You can follow any responses to this entry through the RSS 2.0 feed.

will make one and let you know

Leave a Reply

Your email address will not be published. Required fields are marked *

Facebook
Twitter
Pinterest
Youtube
Instagram
Blogarama - Blog Directory