upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Public Member Functions
GroveCollision Class Reference

API for the Grove Collision Sensor. More...

Detailed Description

The Grove Collision Sensor can detect whether any collision movement or vibration happens. It outputs a low pulse signal when vibration is detected.

grovecollision.jpg
// The was tested with the Grove Collision Sensor
// Instantiate a Grove Collision on digital pin D2
bool collisionState = false;
cout << "No collision" << endl;
while (shouldRun)
{
if (collision->isColliding() && !collisionState)
{
cout << "Collision!" << endl;
collisionState = true;
}
else if (collisionState)
{
cout << "No collision" << endl;
collisionState = false;
}
}

Public Member Functions

 GroveCollision (int pin)
 
 ~GroveCollision ()
 
bool isColliding ()
 

Constructor & Destructor Documentation

GroveCollision ( int  pin)

Grove collision sensor constructor

Parameters
pinDigital pin to use

GroveCollision destructor

Member Function Documentation

bool isColliding ( )
Returns
bool Defines whether something is colliding with sensor

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