RPi::PIGPIO::Device::Switch - Turn on and off a switch
Turn on and off a device connected to a local or remote RapsberryPi
What this actually does is set the GPIO to output and allow you to set the levels to HI or LOW
The device can be enything that accept TTL signal as a command (eg: relay, LED )
use RPi::PIGPIO; use RPi::PIGPIO::Device::Switch; my $pi = RPi::PIGPIO->connect('192.168.1.10'); my $switch = RPi::PIGPIO::Device::Switch->new($pi,4); $switch->on; sleep 3; $switch->off;
Create a new object
Usage:
my $switch = RPi::PIGPIO::Device::Switch->new($pi,$gpio);
Arguments:
$pi - an instance of RPi::PIGPIO
$gpio - GPIO number to which the LED is connected
Turn on the connected device (set the TTL level to HI on the GPIO)
Usage :
$switch->on();
Turn off the led (set the TTL level to LOW on the GPIO)
$switch->off();
Returns the status of the device (checks if the GPIO is set to HI or 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.