Archive

Posts Tagged ‘perl’

Perl Serial Comms on Ubuntu 10.10

February 10th, 2011 Ed No comments

Thanks to @ceejay, here’s some code to set up serial parameters and read from the serial device. Bizarrely the usual method stopped working after an update.
#!/usr/bin/perl
use strict;
use warnings;
use Device::SerialPort;

my $serport="/dev/ttyUSB0";

my $dev = tie (*SERIAL, 'Device::SerialPort', $serport) || die "Can't tie: $!";

$dev->baudrate(4800);
$dev->databits(8);
$dev->parity("none");
$dev->stopbits(1);

#wait for device to exist
while (1) {
my $val = ;
last if $val;
}

while (1) {
my $val = ;
next unless $val;
chomp $val;
print $val . "\n";
#sleep 1;
}
# die if port closes/goes away

Categories: Uncategorized Tags:

Creating an Ambilight mood light for your television

December 3rd, 2009 Ed No comments

In the struggle to find more cool things to do with the arduino, I thought I’d do what someone on twitter had done, make an “Ambilight”, an ambient light behind your TV that colours whatever is behind your TV the same colour as the average colour on your screen – pretty cool! Some Philips TV have this, but I’m not willing to spend extra on that (and I have a TV). I read Szymon Kobalczyk’s Blog and thought I’d give it a whirl. Currently I’m using one of my existing BlinkMs, but I’ve ordered two RGB LED strips and the necessary (hopefully) components from farnell.

The core idea is:

  • Run “Boblightd”, which monitors the screen (excuse the pun) and calculates the average colour, passing it to a program that sends the message via serial to…
  • An arduino listening for colours, and changes the colour of the BlinkM/RGB LED strip accordingly

This is the result of mine on my computer monitor, looks much better in real life (skip to 30-40s for best demo). Will be even better when the RGB LED strip arrives – that’ll be going behind my 42″ TV downstairs.


Read more…

Categories: Arduino Tags: , , , , ,