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;

One thought on “Blink LED in WiringPi-Perl

  1. Andreas, thanks for taking the time to post this sample and also your tips on editing build.sh to get WiringPi-Perl to compile — information about the perl wrapper seems to be very hard to find!

    It’s taken me longer than it should have, but thanks to you I can now make some progress with my Pi and Perl. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *