SRF-08 in Perl
Use the following code to read out the SRF-08 Ultrasonic Range Sensor in Perl:
#!/usr/bin/perl -w
use strict;
use Device::SerialPort;
use bytes;
use Data::Dumper;
use Time::HiRes qw(usleep);
use Term::ANSIColor qw(:constants);
$Term::ANSIColor::AUTORESET = 1;
my $ret; # result byte (0×00 for NOK, otherwise OK)
my $count = 0; # byte count for read / write
my $data; # packed string of bytes
# —————————————————————————–
# Setup serial communications
# —————————————————————————–
#my $port = ‘/dev/ttyUSB0′;
my [...]
September 8, 2009 | Posted by ph
Categories:
Tags: |