Saturday, June 19, 2021

Project 6: Arduino IR (Infrared) Sensor

 Project 6: Arduino IR (Infrared) Sensor 

Main Ideas:

Introduction to the new electronic board IR Sensor and the physical theory behind the IR sensor. IR transmitter or Infrared transmitter is to transmit the infrared waves whereas the work of IR receiver is to receive these infrared waves. This will be used later in Robot project to help Robot to find obstacle once it move backward. Introduction to Serial communications protocol and how to display values from the Arduino board in computer.




Project Description

We will connect the output pin of the IR Sensor to pin 8 (digital pin) and we will read the output value and detect if there is obstacle (output pin low value) near to the IR Sensor we will send alert to be shown in the computer and if no obstacle (output pin high value) then we show message in computer it say all clear .

Circuit

  • IR Sensor
  • 1 LED
  • 1* 1K Resistor
  • Arduino UNO

Code

int Obstacle;

int IR = 8;    // IR sensor output pin connected to digital pin 8

int LED =13;

void setup() {

  pinMode(IR, INPUT);

  pinMode(LED,OUTPUT);

  Serial.begin(9600);

}

void loop() {

  Obstacle = digitalRead(IR);

  if (Obstacle == LOW) {

    digitalWrite(LED,HIGH);

    Serial.println("STOP");

  }

 else {

  digitalWrite(LED,LOW);

   Serial.println("All Clear");

  }

  delay(500);

}

·   

No comments:

Post a Comment