upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions

API for the LED. More...

Detailed Description

UPM module for the LED (or other similar light-emitting diodes). An LED is a p-n junction semiconductor which emits light in response to voltage. The longer wire of an LED connects to the positive seat (anode); the shorter wire connects to the negative seat (cathode). The flat side of the bulb corresponds to the cathode, while the rounded side corresponds to the anode.

led.jpg
// Create the Grove LED object using GPIO pin 2
upm::Led led(2);
// Print the name
std::cout << led.name() << std::endl;
// Turn the LED on and off 10 times, pausing one second
// between transitions
for (int i = 0; i < 10; i++) {
led.on();
upm_delay(1);
led.off();
upm_delay(1);
}
// Delete the Grove LED object

Public Member Functions

 Led (int pin)
 
 Led (std::string name)
 
 ~Led ()
 
upm_result_t write (int value)
 
upm_result_t off ()
 
upm_result_t on ()
 
std::string name ()
 

Constructor & Destructor Documentation

Led ( int  pin)

LED constructor

Parameters
pinPin to use

Here is the call graph for this function:

Led ( std::string  name)

LED constructor

Parameters
nameLinux gpioled device name

Here is the call graph for this function:

~Led ( )

LED destructor

Here is the call graph for this function:

Member Function Documentation

upm_result_t write ( int  value)

Turns the LED on or off, depending on the value. If the value is positive (greater than or equal to 1), the LED is turned on. Otherwise, for 0 or negative values, the LED is turned off.

Parameters
valueTells the LED to turn on (for values >=1) or off (for values <1)
Returns
0 if successful, non-zero otherwise

Here is the call graph for this function:

upm_result_t off ( )

Turns the LED off

Returns
0 if successful, non-zero otherwise
upm_result_t on ( )

Turns the LED on

Returns
0 if successful, non-zero otherwise

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