Blink LED in WiringPi-Perl

I reworked the script from yesterday “Preparing the GPIO basis” using the WiringPi-Perl wrapper.

#!/usr/local/bin/perl -w

use lib "/appco.de/WiringPi-Perl";

require "wiringpi.pm";

if (wiringpic::wiringPiSetup () == -1)
{ exit 0};

# set pin #0 (marked with #17 on the T-Cobbler) to mode OUTPUT
wiringpic::pinMode (0, 1);

while (1){
  # LED off
  wiringpic::digitalWrite (0, 0);
  wiringpic::delay (500); # milliseconds

  # LED on
  wiringpic::digitalWrite (0, 1);
  wiringpic::delay (500); # milliseconds
}

While digging into the details I found a quite useful overview of the function wrappers in the file ../WiringPi-Perl/wiringpi.pm

package wiringpi;

*wiringPiSetup = *wiringpic::wiringPiSetup;
*wiringPiSetupSys = *wiringpic::wiringPiSetupSys;
*wiringPiSetupGpio = *wiringpic::wiringPiSetupGpio;
*wiringPiGpioMode = *wiringpic::wiringPiGpioMode;
*pullUpDnControl = *wiringpic::pullUpDnControl;
*pinMode = *wiringpic::pinMode;
*digitalWrite = *wiringpic::digitalWrite;
*pwmWrite = *wiringpic::pwmWrite;
*digitalRead = *wiringpic::digitalRead;
*shiftOut = *wiringpic::shiftOut;
*shiftIn = *wiringpic::shiftIn;
*delay = *wiringpic::delay;
*delayMicroseconds = *wiringpic::delayMicroseconds;
*millis = *wiringpic::millis;
*serialOpen = *wiringpic::serialOpen;
*serialClose = *wiringpic::serialClose;
*serialPutchar = *wiringpic::serialPutchar;
*serialPuts = *wiringpic::serialPuts;
*serialDataAvail = *wiringpic::serialDataAvail;
*serialGetchar = *wiringpic::serialGetchar;
*serialPrintf = *wiringpic::serialPrintf;

GPIO Pin Mapping

I was looking for an option to use the GPIO Pins with Perl directly. Thanks to Gordon the solution was pretty easy with the wiringPi framework and the perl wrapper wiringPi-Perl created by Gadgetoid. Gordon also created the useful PIN mapping overview which I used for my own table shown below which also includes the translation to the Ardafruit T-Cobbler.

PIN Mapping