Arduino Project Hub

IR Distance Sensor

GP2Y0A02YK0F IR Distance Sensor (20-150 cm) test distance in Cm and In

  • 0 views
  • 0 comments
  • 0 respects

Components and supplies

About this project

GP2Y0A02YK0F

This is a start guide for using GP2Y0A02YK0F distance sensor with Arduino and TFT Touch Screen.

The Sharp GP2Y0A02YK0F is an optical distance sensor. It is composed of an infrared LED along with position detector device (PSD) and an integrated processor in charge of calculating the distance.

The sensor continuously scans the objects in front of it and provides the output with an analog voltage reference, so we can use the analog inputs of Arduino to read the value of the distance.

The measuring range is from 20 to 150 cm, maintaining a high degree of accuracy throughout the range. The supply voltage is 4.5 to 5.5V and the current consumption of 33mA. The refresh interval between measurements is about 80ms.

The sensor is less sensitive to the color and reflectivity of the detected object, nor to the ambient temperature. However, it can be affected by ambient light if it receives a high degree of brightness directly, especially when used outdoors. They can also provide incorrect measurements when detecting transparent or very bright objects, especially glass and mirrors.

The Sharp sensor is more accurate at medium and long distances, however it can not operate in short distances (< 20cm).

Schematics

basic schematic
Ir bb vzjvobelke

Code

ATmega32u4_IRArduino
/*
*	Author		: Zavala Ortiz Vicente Arturo.
*	language	: .ino
*	Date		: September 12 2014 5:11:12 PM
*	Name		: ATmega32u4_IR.ino
*	Description : GP2Y0A02YK0F IR Distance Sensor (20-150 cm) test distance in Cm and In
*/


#include "TFT.h"
#include "GP2Y0A02YK0F.h"

GP2Y0A02YK0F irSensor;
int cm;

void setup() 
{
  Tft.init();
  irSensor.begin(A0);	//	Assign A0 as sensor pin
}

void loop()
{

  cm = irSensor.getDistanceCentimeter();
  
  Tft._puts("\nDistance : ");
  Tft._print_dec(cm);  
  Tft._puts(" CM");
  
  Tft._puts("\nDistance : ");
  Tft._printdec(cm / 2.54);
  Tft._puts(" IN");

  delay(500); 
  
  Tft.clrscr();
}

Comments

Similar projects you might like

Arduino 101 - Intel Curie Pattern Matching Dress

Project tutorial by Kitty Yeung

  • 2,094 views
  • 9 comments
  • 19 respects

Arduino Morse Code Machine

Project tutorial by Vlada Krsmanovic

  • 723 views
  • 0 comments
  • 11 respects

Arduino Laser Tripwire

Project tutorial by Ian Cumming

  • 2,646 views
  • 2 comments
  • 18 respects

PlatformIO for Visual Studio Code

by formulahendry

  • 810 views
  • 0 comments
  • 6 respects

Smart Home Sensor Node

Project tutorial by vincent wong

  • 871 views
  • 0 comments
  • 6 respects

ESP8266 + L298N Motor Drive + Smartphone

by luciorocha

  • 1,653 views
  • 2 comments
  • 7 respects
Add projectSign up / Login