upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Public Member Functions | List of all members

API for the RPR220-based Grove IR Reflective Sensor. More...

Detailed Description

UPM module for the Grove IR reflective sensor. The sensitivity can be adjusted with the potentiometer on the sensor module. It has a range of approximately 15 mm, and a quick response time.

It detects high-contrast dark areas on a light background.

This module allows the user to determine the current status (black detected or not). Additionally, if desired, an interrupt service routine (ISR) can be installed that is called when black is detected. Either method can be used, depending on your use case.

rpr220.jpg
// This example uses a simple method to determine current status
// Instantiate an RPR220 digital pin D2
while (true) {
if (sensor.blackDetected())
System.out.println("Black detected");
else
System.out.println("Black NOT detected");
Thread.sleep(100);
}
// This example uses an interrupt handler to increment a counter
// Instantiate an RPR220 digital pin D2
IsrCallback callback = new RPRISR();
sensor.installISR(callback);
while (true) {
System.out.println("Counter: " + counter);
Thread.sleep(1000);
}

Public Member Functions

synchronized void delete ()
 
 RPR220 (int pin)
 
boolean blackDetected ()
 
void installISR (IsrCallback cb)
 
void uninstallISR ()
 

Constructor & Destructor Documentation

RPR220 ( int  pin)

RPR220 constructor

Parameters
pinDigital pin to use

Member Function Documentation

boolean blackDetected ( )

Gets the status of the pin; true means black has been detected

Returns
True if the sensor has detected black
void uninstallISR ( )

Uninstalls the previously installed ISR


The documentation for this class was generated from the following file: