RPi::PIGPIO - remotely control the GPIO on a RaspberryPi using the pigpiod daemon
This module impements a client for the pigpiod daemon, and can be used to control the GPIO on a local or remote RaspberryPi
This is the list of error codes returned by various methods (exported constant and the equivalent value) PI_BAD_GPIO => PI_BAD_MODE => PI_NOT_PERMITTED =>
Connects to the pigpiod running on the given IP address/port and returns an object that will allow us to manipulate the GPIO on that Raspberry Pi
Disconnect from the gpiod daemon.
The current object is no longer usable once we disconnect.
Returns the mode of a given GPIO pin
Return values : 0 => PI_INPUT 1 => PI_OUTPUT 2 => PI_ALT0 3 => PI_ALT1 4 => PI_ALT2 5 => PI_ALT3 6 => PI_ALT4 7 => PI_ALT5
Sets the GPIO mode
Usage:
$pi->set_mode(17, PI_OUTPUT);
Valid values for $mode are exported as constants and are : PI_INPUT, PI_OUTPUT, PI_ALT0, PI_ALT1, PI_ALT2, PI_ALT3, PI_ALT4, PI_ALT5
Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_MODE, or PI_NOT_PERMITTED.
Sets the voltage level on a GPIO pin to HI or LOW
Note: You first must set the pin mode to PI_OUTPUT
Usage :
$pi->set_level(17, HI); or $pi->set_level(17, LOW);
Register a method you want to be called when the level on a given pin changes
Usage : $pi->callback($gpio, $edge, $method_ref);
Params : $gpio - number of the GPIO pin we want to monitor $edge - on of RISING_EDGE, FALLING_EDGE, EITHER_EDGE $callback_method_name - *name* the method (as string) that you want to be called when an event is detected. The metod will be called with the gpio number, edge and tick as parameters
sub process_callback { my ($gpio, $edge, $tick) = @_; ... }; $pi->callback(17, EITHER_EDGE, 'process_callback');
Returns the is of the callback. This ID must be used when you call callback_cancel
callback_cancel
Cancel a callback registered with callback
callback
Usage: $pi->callback_cancel(5);
Params: $callback_id - ID of the callback you want to cancel, as returned by callback
This function sends a trigger pulse to a GPIO. The GPIO is set to level for pulseLen microseconds and then reset to not level.
Params (in this order): $gpio - number of the GPIO pin we want to monitor $length - pulse length in microseconds $level - level to use for the trigger (HI or LOW)
Usage: $pi->gpio_trigger(4,17,LOW);
To install RPi::PIGPIO, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RPi::PIGPIO
CPAN shell
perl -MCPAN -e shell install RPi::PIGPIO
For more information on module installation, please visit the detailed CPAN module installation guide.