RPi-WiringPi
view release on metacpan or search on metacpan
lib/RPi/WiringPi.pm view on Meta::CPAN
Optional, String: A label stored alongside the pin's registration (visible in
the metadata store and used by the test suite). Defaults to none.
=head2 rtc
Creates a new L<RPi::RTC::DS3231> object which provides access to the C<DS3231>
or C<DS1307> real-time clock modules.
See the linked documentation for full documentation on usage, or the
L<RPi::WiringPi::FAQ> for some usage examples.
Parameters:
$i2c_addr
Optional, Integer: The I2C address of the RTC module. Defaults to C<0x68> for
the C<DS3231> unit.
=head2 eeprom
Creates and returns a new L<RPi::EEPROM::AT24C32> object for reading and writing
to.
See the linked documentation for full documentation on usage, parameters or the
L<RPi::WiringPi::FAQ> for some usage examples.
=head2 expander
Creates a new L<RPi::GPIOExpander::MCP23017> GPIO expander chip object. This
adds an additional 16 pins across two banks (8 pins per bank).
See the linked documentation for full documentation on usage, or the
L<RPi::WiringPi::FAQ> for some usage examples.
Parameters:
$i2c_addr
Optional, Integer: The I2C address of the device. Defaults to C<0x20>.
$expander
Optional, String: The GPIO expander device type. Defaults to C<MCP23017>, and
currently, this is the only option available.
=head2 serial($device, $baud)
Creates a new L<RPi::Serial> object which allows basic read/write access to a
serial bus.
See the linked documentation for full documentation on usage, or the
L<RPi::WiringPi::FAQ> for usage examples.
NOTE: On the Pi 3 and Pi 4, Bluetooth occupies the primary UART, leaving the
header pins (14, 15) on the mini-UART (C</dev/ttyS0>). To put the full PL011
UART back on the header you must disable Bluetooth in the
C</boot/firmware/config.txt> file (C</boot/config.txt> on releases before
Bookworm):
dtoverlay=pi3-disable-bt-overlay
On the Pi 5, Bluetooth has its own dedicated UART, so no C<disable-bt> overlay
is needed; simply enable the header UART (C</dev/ttyAMA0>) with C<enable_uart=1>.
=head2 servo($pin_num)
This method configures PWM clock and divisor to operate a typical 50Hz servo,
and returns a special L<RPi::Pin> object. These servos have a C<left> pulse of
C<50>, a C<centre> pulse of C<150> and a C<right> pulse of C<250>. On exit of
the program (or a crash), we automatically clean everything up properly.
Parameters:
$pin_num
Mandatory, Integer: The pin number (technically, this *must* be C<18> on the
Raspberry Pi 3, as that's the only hardware PWM pin.
%pwm_config
Optional, Hash. This parameter should only be used if you know what you're
doing and are having very specific issues.
Keys are C<clock> with a value that coincides with the PWM clock speed. It
defaults to C<192>. The other key is C<range>, the value being an integer that
sets the range of the PWM. Defaults to C<2000>.
Example:
my $servo = $pi->servo(18);
$servo->pwm(50); # all the way left
$servo->pwm(250); # all the way right
=head2 shift_register($base, $num_pins, $data, $clk, $latch)
Allows you to access the output pins of up to four 74HC595 shift registers in
series, for a total of eight new output pins per register. Numerous chains of
four registers are permitted, each chain uses three GPIO pins.
Parameters:
$base
Mandatory: Integer, represents the number at which you want to start
referencing the new output pins attached to the register(s). For example, if
you use C<100> here, output pin C<0> of the register will be C<100>, output
C<1> will be C<101> etc.
$num_pins
Mandatory: Integer, the number of output pins on the registers you want to use.
Each register has eight outputs, so if you have a single register in use, the
maximum number of additional pins would be eight.
$data
Mandatory: Integer, the GPIO pin number attached to the C<DS> pin (14) on the
shift register.
$clk
( run in 1.165 second using v1.01-cache-2.11-cpan-7fcb06a456a )