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!
Karen Li
Created November 30, 2015 © GPL3+

HW 11: 2YA21 Sharp Infrared Proximity Sensor

Details about our experimentation with a 2YA21 Sharp Infrared Proximity Sensor

Showcase (no instructions)57
HW 11: 2YA21 Sharp Infrared Proximity Sensor

Story

Read more

Code

Proximity Sensor Code

C/C++
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

Karen Li

Karen Li

11 projects • 0 followers

Comments