Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^12: Controlling USB on Raspberry Pi

by stevieb (Canon)
on Dec 14, 2020 at 17:32 UTC ( #11125176=note: print w/replies, xml ) Need Help??

in reply to Re^11: Controlling USB on Raspberry Pi
in thread Controlling USB on Raspberry Pi

Way too much file system work.

use warnings; use strict; use RPi::Pin; use RPi::Const qw(:all); my $curtain_relay_pin = 5; my $pin = RPi::Pin->new($curtain_relay_pin); $pin->mode(OUTPUT); if (...) { $pin->write(LOW); } elsif ($pin->read == LOW) { $pin->write(HIGH); }

Done. That assumes an active low relay. No need for super user access whatsoever. No touching of the file system whatsoever. Executed in fast C code that has access directly to the GPIO registers. No need for the entire RPi::WiringPi either. However, you don't get the pin security and cleanup that's provided by the encompassing distribution, but I digress.

The RPi::Pin module provides access to all related GPIO pin functionality... pull up/down resistors, PWM, interrupts, setting of alternate pin modes etc.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11125176]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2022-08-19 11:55 GMT
Find Nodes?
    Voting Booth?

    No recent polls found