IR Distance Sensor

IR Distance Sensor

tilt

This SHARP distance sensor bounces IR off objects to determine how far away they are.


Components

1 x IR Distance Sensor
1 x Arduino Uno
3 x Alligator Clips
jumper wires
 

Setup


Arduino sketch

Adapted from Adafruit example.
Arduino Sketch:

//Adapted from the article: http://bildr.org/2012/11/force-sensitive-resistor-arduino

int DSR_Pin = A0; //analog pin 0


void setup(){
  // for printing
  Serial.begin(9600);
}

void loop(){
  // capture the readings of the sensor
  int DSRReading = analogRead(DSR_Pin); 
  // print the readings
  Serial.println(DSRReading);
  delay(250); //just here to slow down the output for easier reading
}