Sharp Distance Sensor GP2Y0A51SK0F
Interfacing
with Arduino Uno
By
Engr.Habib Ur Rehman
Following
Components/Equipment are required to perform task.
3.
Breadboard
4.Jumper Wires (https://piees.pk/product-category/jumper-wires/)
Arduino Program:
#include
<SharpIR.h>
#define
ir A0
#define
model 20150
SharpIR
SharpIR(ir, model);
void
setup() {
Serial.begin(9600);}
void
loop() {
delay(2000);
unsigned long pepe1=millis();
int dis=SharpIR.distance();
Serial.print("Mean distance: ");
Serial.println(dis);
unsigned long pepe2=millis()-pepe1;
Serial.print("Time taken (ms): ");
Serial.println(pepe2); }
Note:
·
Sharp
IR Master Library folder should be added in Arduino library folder “C:\Program Files\Arduino\libraries”
·
This
Module work good for a short distance