upm  1.5.0
Sensor/Actuator repository for libmraa (v1.8.0)
Public Member Functions

API for the Collision Sensor. More...

Detailed Description

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

// The was tested with the Collision Sensor
// Instantiate a Collision on digital pin D2
upm::Collision collision(2);
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

 Collision (int pin)
 ~Collision ()
bool isColliding ()

Constructor & Destructor Documentation

Collision ( int  pin)

Collision sensor constructor

pinDigital pin to use
~Collision ( )

Collision destructor

Member Function Documentation

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

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