upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Public Member Functions

API for the Grove Relay. More...

Detailed Description

UPM module for the Grove relay switch. 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++ ) {
relay->on();
if ( relay->isOn() )
std::cout << relay->name() << " is on" << std::endl;
sleep(1);
relay->off();
if ( relay->isOff() )
std::cout << relay->name() << " is off" << std::endl;
sleep(1);
}
// Delete the relay switch object
delete relay;
groverelay.jpg

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

Parameters
gpioPin 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.

Returns
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.

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

Defines whether the relay switch is closed.

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

Defines whether the relay switch is open.

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

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