Wednesday, April 22, 2020

Sharp Distance Sensor GP2Y0A51SK0F Interfacing with Arduino Uno By Engr.Habib Ur Rehman




                  Sharp Distance Sensor GP2Y0A51SK0F      
                                  Interfacing with Arduino Uno
                 By Engr.Habib Ur Rehman


Components/Equipment Required:
           Following Components/Equipment are required to perform task.
2.    Sharp Distance Sensor GP2Y0A51SK0F (https://piees.pk/product/ir-distance-sensor-gp2y0a41sk0f/)     
3.    Breadboard
                              4.Jumper Wires (https://piees.pk/product-category/jumper-wires/)
Circuit Diagram:


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