Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Matthew Chiang
Created November 30, 2015

Distance Measuring Sensor Assignment

Testing a Sharp GP2Y0A21YK IR Proximity Sensor (actually a distance measuring sensor)

BeginnerShowcase (no instructions)3,757
Distance Measuring Sensor Assignment

Things used in this project

Story

Read more

Code

distance-sensor-sketch

Java
Open the serial monitor to see the analogRead values
int sensorPin = 0; //analog pin 0

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

void loop(){
  int val = analogRead(sensorPin);
  Serial.println(val);

  //just to slow down the output - remove if trying to catch an object passing by
  delay(100);

}

Credits

Matthew Chiang

Matthew Chiang

16 projects • 9 followers

Comments