upm  1.3.0
Sensor/Actuator repository for libmraa (v1.7.0)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions
GroveRelay Class Reference

API for the Grove Relay. More...

Detailed Description

UPM module for the Grove relay switch. The Grove relay is a digital normally-open switch that uses low voltage or current to control a higher voltage and/or higher current. When closed, the indicator LED lights up and current is allowed to flow.

// Create the relay switch object using GPIO pin 0
// Close and then open the relay switch 3 times,
// waiting one second each time. The LED on the relay switch
// will light up when the switch is on (closed).
// The switch will also make a noise between transitions.
for ( int i = 0; i < 3; i++ ) {
if ( relay->isOn() )
std::cout << relay->name() << " is on" << std::endl;
if ( relay->isOff() )
std::cout << relay->name() << " is off" << std::endl;
// Delete the relay switch object
delete relay;

Public Member Functions

 GroveRelay (unsigned int pin)
 ~GroveRelay ()
mraa_result_t on ()
mraa_result_t off ()
bool isOn ()
bool isOff ()
- Public Member Functions inherited from Grove
std::string name ()

Additional Inherited Members

- Protected Attributes inherited from Grove
std::string m_name

Constructor & Destructor Documentation

GroveRelay ( unsigned int  pin)

Grove relay constructor

pinPin to use
~GroveRelay ( )

Grove relay destructor

Member Function Documentation

mraa_result_t on ( )

Sets the relay switch to on (closed). This allows current to flow and lights up the indicator LED.

0 if successful, non-zero otherwise
mraa_result_t off ( )

Sets the relay switch to off (open). This stops current from flowing and the indicator LED is not lit.

0 if successful, non-zero otherwise
bool isOn ( )

Defines whether the relay switch is closed.

True if the switch is on (closed), false otherwise
bool isOff ( )

Defines whether the relay switch is open.

True if the switch is off (open), false otherwise
Inheritance diagram for GroveRelay:
Inheritance graph
Collaboration diagram for GroveRelay:
Collaboration graph

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