vk4tec

Need a hand please : Perl GPIO

Mon May 09, 2016 12:06 pm

Can someone talk me through getting GPIO working under perl please.

I need to flash some LED's

Thanks in advance

Andrew

User avatar
joan
Posts: 16247
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Need a hand please : Perl GPIO

Mon May 09, 2016 12:11 pm


vk4tec

Re: Need a hand please : Perl GPIO

Mon May 09, 2016 1:01 pm

Thank you I will try this tomorrow

I will leave it logging over night

vk4tec

Re: Need a hand please : Perl GPIO

Tue May 10, 2016 11:35 am

I was looking at the PERL examples.

How do I "get and install" the bcm2835 library
How do I "get and install" the Device::BCM2835 perl library ?

Is CPAN involved ? APT-GET ?

Andrew

Wolfinze
Posts: 4
Joined: Mon May 02, 2016 10:36 pm

Re: Need a hand please : Perl GPIO

Tue May 10, 2016 12:15 pm


Can you help me ??
I need to read a pin of raspberry pi, and when the pin is close to the ground, i want to count the time, and the pin is not close i want to stop the counting... and then i want to send to network a file with that time...

Massi
Posts: 1691
Joined: Fri May 02, 2014 1:52 pm
Location: Italy

Re: Need a hand please : Perl GPIO

Tue May 10, 2016 12:20 pm

like this?

viewtopic.php?f=32&t=146793&p=966533#p966533

where is your code?
what problem are you getting?

you won't get your homeworks made.
at least not by me


vk4tec

Re: Need a hand please : Perl GPIO

Wed May 18, 2016 3:08 pm

Anyone able to flash an led using perl ?

Heater
Posts: 19592
Joined: Tue Jul 17, 2012 3:02 pm

Re: Need a hand please : Perl GPIO

Wed May 18, 2016 3:46 pm

vk4tec,
Anyone able to flash an led using perl ?
No.

But only because I think it's a crazy idea.

People flash LEDs on the Pi all the time from C/C++, Python, C#, Java, Javascript. Why on Earth do you want to do it from Perl?

I know that is not very helpful. But horses for courses and all that.
Slava Ukrayini.

Massi
Posts: 1691
Joined: Fri May 02, 2014 1:52 pm
Location: Italy

Re: Need a hand please : Perl GPIO

Wed May 18, 2016 5:52 pm

Heater wrote:vk4tec,
Anyone able to flash an led using perl ?
No.

But only because I think it's a crazy idea.

People flash LEDs on the Pi all the time from C/C++, Python, C#, Java, Javascript. Why on Earth do you want to do it from Perl?

I know that is not very helpful. But horses for courses and all that.
easy way to access gpio from every language: write something ask pigpiod to do that for you.
flashing a led from php took something like 10 minutes to connect to pigpio and get the led lit..

Nettmaus
Posts: 1
Joined: Sat Sep 02, 2017 11:08 pm

Re: Need a hand please : Perl GPIO

Sat Sep 02, 2017 11:18 pm

Heater wrote:
Wed May 18, 2016 3:46 pm
vk4tec,
Anyone able to flash an led using perl ?
No.

But only because I think it's a crazy idea.

People flash LEDs on the Pi all the time from C/C++, Python, C#, Java, Javascript. Why on Earth do you want to do it from Perl?

I know that is not very helpful. But horses for courses and all that.

Please do not deprecate other languages. Setting fire to people because they seek a solution in "language X" defeats the whole purpose of learning.

To answer the original question, the package is in fact from CPAN:
http://search.cpan.org/~mikem/Device-BC ... BCM2835.pm

To the OP: If you wish to conform to the masses, then learn how this works in Perl, then look at Python examples, and perform differential analysis to see how Perl and Python differ. Otherwise, use the language you are comfortable with and do not be deterred by the loud and misguided adherents to single language philosophy.

edpannelap
Posts: 1
Joined: Wed Aug 07, 2019 12:51 pm

Re: Need a hand please : Perl GPIO

Wed Aug 07, 2019 1:01 pm

Got it to work in Perl on Rasbian buster lite:


It took some additional download / copile / installs
Get latest version of bcm2835 lib:

Code: Select all

wget http://www.open.com.au/mikem/bcm2835/bcm2835-1.59.tar.gz
tar xvfz bcm2835-1.59.tar.gz 
cd bcm2835-1.59/
 ./configure 
 make
 sudo make install
  
get the wiringpi lib using apt-get

Code: Select all

sudo apt-get install wiringpi
 
now get the perl lib for these libs and the RPi::Pin using cpan

Code: Select all

sudo cpan -i Device::BCM2835
sudo cpan -i WiringPi::API
 sudo cpan -i RPi::Pin
All done

Use some example code like this :

Code: Select all

use RPi::Pin;
use RPi::Const qw(:all);
my $pin = RPi::Pin->new(4);
$pin->mode(INPUT);
$pin->write(LOW);
$pin->set_interrupt(EDGE_RISING, ‘main::pin4_interrupt_handler’);
while (1) {
   my $num = $pin->num;
   my $mode = $pin->mode;
   my $state = $pin->read;
   print “pin number $num is in mode $mode with state $state\n”;
   sleep(1);
}
sub pin4_interrupt_handler {
   print “in interrupt handler\n”;
}

Return to “General discussion”