Preparing the GPIO basis

To use GPIO with perl on the RaspberryPi the following installations are necessary:

  1. C library for Broadcom BCM 2835 from
  2. BCM2835 perl library from CPAN

To install the C library for Broadcom BCM 2835 the following steps are required:

tar zxvf bcm2835-1.17.tar.gz
cd bcm2835-1.17
sudo make test
sudo make install

For the BCM 2835 perl library the installation works as outlined below:

tar –xvfz Device-BCM2835-1.6.tar.gz
perl Makefile.PL
sudo make test
sudo make install

To verify the functionality I used the following test bed

Blink LED Breadboard

Blink LED Schaltplan

I used the example script from


use Device::BCM2835;
use strict;

# call set_debug(1) to do a non-destructive test on non-RPi hardware
|| die "Could not init library";

# Blink pin 11:
# Set RPi pin 11 to be an output

while (1){
  # Turn it on
  Device::BCM2835::gpio_write(&Device::BCM2835::RPI_GPIO_P1_11, 1);
  Device::BCM2835::delay(500); # Milliseconds
  # Turn it off
  Device::BCM2835::gpio_write(&Device::BCM2835::RPI_GPIO_P1_11, 0);
  Device::BCM2835::delay(500); # Milliseconds

This script lets the LED blink for 500 milliseconds and continues to run until you stop it with ctrl+c.

Blink LED Wiring

Leave a Reply

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