sensor-experiments

Introduction

This experiment demonstrates how to use an infrared distance sensor to measure the distance of objects using an Arduino.

Components Needed

No Ads Available.

Circuit Setup

  1. Connect the VCC and GND pins of the infrared sensor to the 5V and GND pins on the Arduino.
  2. Connect the output of the infrared sensor to an analog input pin (e.g., A0) on the Arduino.

The infrared sensor detects the distance to objects based on the reflection of infrared light.

Code for Infrared Distance Measurement

Upload the following code to your Arduino to measure distance:


const int sensorPin = A0;
int distance;

void setup() {
  Serial.begin(9600);
}

void loop() {
  distance = analogRead(sensorPin);
  Serial.print("Distance: ");
  Serial.println(distance);
  delay(1000);
}
            

Explanation

The infrared sensor sends out infrared light and measures the amount of reflection that comes back, calculating the distance to the object based on this feedback.

Troubleshooting

Contact Us

If you have any questions or inquiries, feel free to reach out to us at Microautomation.no@icloud.com .

Follow our Socials for the newest updates!