-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
Description
# !/usr/bin/perl
# test1.pl
use wiringpi;
use constant {
OUTPUT=>1,
INPUT=>0,
HIGH=>1,
LOW=>0
};
$SIG{'INT'}=&safe_exit;
$SIG{'QUIT'}=&safe_exit;
$SIG{**DIE**}=&safe_exit;
print("Raspberry Pi wiringPi test program\n");
if( wiringpi::wiringPiSetup()==-1 ){
die 1;
}
for( my $pin=0;$pin<8;++$pin ){
wiringpi::pinMode($pin,OUTPUT);
}
wiringpi::pinMode(8,INPUT);
@data=(
[0,1,1],
[1,1,1],
[0,0,0],[2,1,1],
[1,0,0],[3,1,1],
[2,0,0],[4,1,1],
[3,0,0],[5,1,1],
[4,0,0],[6,1,1],
[5,0,0],[7,1,1],
[6,0,1],
[7,0,1],
[7,1,1],
[6,1,1],
[7,0,0],[5,1,1],
[6,0,0],[4,1,1],
[5,0,0],[3,1,1],
[4,0,0],[2,1,1],
[3,0,0],[1,1,1],
[2,0,0],[0,1,1],
[1,0,1],
[0,0,1],
[9,9,9]
);
my $inc=0;
while( 1==1 ){
my( $pin,$state,$duration )=@{$data[$inc]};
if( $pin+$state+$duration==27 ){
$inc=0;
next;
}
wiringpi::digitalWrite($pin,$state);
if( wiringpi::digitalRead(8)==LOW ){
wiringpi::delay($duration_10);
}else{
wiringpi::delay( $duration_100 );
}
++$inc;
}
# this just turns off all the LEDs when you exit the script
sub safe_exit{
for( my $pin=0;$pin<8;++$pin ){
wiringpi::digitalWrite($pin,LOW);
}
exit 1;
}