++ed by:
CREDO BINJOY SREZIC
1 non-PAUSE user
Author image Gligan Calin Horea
and 1 contributors

NAME

RPi::PIGPIO::Device::Switch - Turn on and off a switch

DESCRIPTION

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 )

SYNOPSIS

    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;

METHODS

new

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

on

Turn on the connected device (set the TTL level to HI on the GPIO)

Usage :

    $switch->on();

off

Turn off the led (set the TTL level to LOW on the GPIO)

Usage :

    $switch->off();

status

Returns the status of the device (checks if the GPIO is set to HI or LOW)