Αισθητήρας IR αναγνώρισης εμποδίου με Arduino

Αποφυγή σύγκρουσης υπερύθρων Arduino
Μονάδα ανιχνευτή σύγκρουσης. Αυτό είναι ένα ακόμη από αυτά τα δομοστοιχεία με ενδιαφέρουσες δυνατότητες. Θα μπορούσατε, για παράδειγμα, να ακούσετε ένα συναγερμό όταν πλησιάσετε πολύ κοντά κάποιο αντικείμενο ή θα μπορούσατε να αλλάξετε την κατεύθυνση ενός ρομπότ ή ενός οχήματος.

Η συσκευή αποτελείται από έναν υπέρυθρο πομπό, έναν ανιχνευτή υπερύθρων και ένα κύκλωμα υποστήριξης. Απαιτεί μόνο τρεις συνδέσεις. Όταν εντοπίσει ένα εμπόδιο εντός εμβέλειας, θα στείλει χαμηλή απόδοση.

Arduino IR Collision Detection Module Pin Outs

Pin, Control Indicator Description
Vcc 3.3 to 5 Vdc Supply Input
Gnd Ground Input
Out Output that goes low when obstacle is in range
Power LED Illuminates when power is applied
Obstacle LED Illuminates when obstacle is detected
Distance Adjust Adjust detection distance. CCW decreases distance.
CW increases distance.
IR Emitter Infrared emitter LED
IR Receiver Infrared receiver that receives signal transmitted by Infrared emitter.

IR Collision Detection Module Arduino Tutorial Hook Up

Μετακινήστε το χέρι σας προς τα LED IR. Καθώς πλησιάζετε, θα ανάψει η ενδεικτική λυχνία εξόδου της μονάδας και η ενδεικτική λυχνία LED 13 για το Arduino.

ΚΩΔΙΚΑΣ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              

const int analogInPin = A0;  // Analog input pin that the receiver is attached to

int sensorValue = 0;        // value read from the receiver

 

void setup() {

  // initialize serial communications at 9600 bps:

  Serial.begin(9600);

  //initialize the indicator LED:

  pinMode(13, OUTPUT);

}

 

void loop() {

  // read the analog in value:

  sensorValue = analogRead(analogInPin);

 

  // print the results to the serial monitor:

  Serial.print("\nsensor = ");

  Serial.print(sensorValue);

  //the threshold found fron analog In Out program was when object is detected, the sensor value is below 100

  //set the threshold whihc you get

  //the threshold varies for different sets of emitter-receiver pairs

  if(sensorValue < 200){ //checks if object is there or not

    digitalWrite(13, HIGH);

    Serial.print("\nObject Detected");

    }

  else{

    digitalWrite(13, LOW);

    Serial.print("\nNo object in Front");

    }

  delay(500);

}