Arduino library that allows to acquire distance data from Sharp IR sensors
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples/getDistance
src Minor changes to licensing info Jul 20, 2018
CHANGELOG.md Updated the Changelog Jul 20, 2018
LICENSE.md Minor changes to licensing info Jul 20, 2018
README.md README Cleanup Jul 20, 2018
keywords.txt Adding RSYNTAXTEXTAREA_TOKENTYPE fields Jul 20, 2018
library.properties Updated library.properties for the release Jul 20, 2018

README.md

SharpIR

An Arduino library that allows to acquire distance data from a Sharp analog distance sensor

Project status badge License badge
Arduino Library specification badge Arduino IDE compatibility badge
Keep a Changelog specification badge Semantic Versioning specification badge

Currently supported sensor models

  • GP2Y0A41SK0F
  • GP2Y0A21YK0F
  • GP2Y0A02YK0F

Usage

  • Adding the library to the sketch
#include <SharpIR.h>
  • Creating an istance
SharpIR sensorName(sensorModel, sensorPin);
sensorName	: the name of the object   
sensorModel	: the model code of the sensor (e.g. GP2YA41SK0F)  
sensorPin	: the analog pin where the sensor Vout pin is attached  
  • Acquiring data
sensorName.getDistance();
sensorName.getDistance( avoidBurstRead );
avoidBurstRead	: can be true or false

The above method returns an uint8_t type value that is the distance in centimeters from the sensor and the object in front of it.
By default burst reads are avoided but this causes a delay of 20ms on every call. In order to speed up the sketch is possible to allow bust reads by setting the parameter avoidBurstRead to false, in this way:

sensorName.getDistance( false );

License

Creative Commons License
The SharpIR Library by Giuseppe Masino is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License

If you need permissions that are beyond the scope of this license, you can ask me through this contacts, in order of preference:

The license text can be found in the LICENSE.md file