Overview
fit-statUSB isn't all work and no play. It can be used to implement things which are colorful and entertaining. In this case it is configured to be a random color generator.
Random Color Generator In Action
Unfortunately, the camera image is a bit washed out. In reality, the effect is very good
Perl App
#!/usr/bin/perl -w
#
#fitrandom.pl
# Darryl Hassell 8/8/2018
use Tk;
use Device::SerialPort;
use Time::HiRes ('sleep');
# Define & Initialize Variables
my $red_random_dec = 255;
my $green_random_dec = 255;
my $blue_random_dec = 255;
my $red_random_hex = 'FF';
my $green_random_hex = 'FF';
my $blue_random_hex = 'FF';
my $random_color = '#FFFFFF';
# Configure Serial Port
my $port = Device::SerialPort -> new("/dev/ttyACM0");
$port -> baudrate(115200);
$port -> databits(8);
$port -> parity("none");
$port -> stopbits(1);
$port -> write_settings;
# Set Sleep Delay After Writes in Seconds
our $delay = 0.1;
# Initialize fit-statUSB to Max Brightness White
$port -> write("F0.1\n");
$port -> purge_rx;
$port -> write("$random_color\n");
$port -> purge_rx;
# Create Main Window
$WinMain = MainWindow->new;
$WinMain -> resizable (0,0);
# Label Main Window
$myframe = $WinMain -> Frame ->pack();
$Mem_Use_Label = $myframe -> Label (-text => 'fit-statUSB Random Color Demo', -background => "$random_color", -foreground => "black", -font => "helvetica 9 bold")->pack(-ipadx => 20,-ipady => 20);
# Exit Program Button
$stopbutton = $myframe -> Button (-text => 'Exit', -command => \&Exit, -foreground => 'black', -background => 'lightblue');
$stopbutton -> pack (-side => 'bottom');
$WinMain -> repeat(500, \&GetRandom);
MainLoop();
################################ Exit Program ################################
sub Exit {
$port -> write("#000000\n");
$port -> purge_rx;
sleep($delay);
exit;
}
################################ Generate Random Colors ################################
sub GetRandom {
########## Red ##########
my $red_random_dec1 = int(rand(15)) + 1;
my $red_random_hex1 = sprintf("%X", $red_random_dec1);
my $red_random_dec2 = int(rand(15)) + 1;
my $red_random_hex2 = sprintf("%X", $red_random_dec2);
########## Green ##########
my $green_random_dec1 = int(rand(15)) + 1;
my $green_random_hex1 = sprintf("%X", $green_random_dec1);
my $green_random_dec2 = int(rand(15)) + 1;
my $green_random_hex2 = sprintf("%X", $green_random_dec2);
########## Blue ##########
my $blue_random_dec1 = int(rand(15)) + 1;
my $blue_random_hex1 = sprintf("%X", $blue_random_dec1);
my $blue_random_dec2 = int(rand(15)) + 1;
my $blue_random_hex2 = sprintf("%X", $blue_random_dec2);
my $random_color = '#'.$red_random_hex1.$red_random_hex2.$green_random_hex1.$green_random_hex2.$blue_random_hex1.$blue_random_hex2;
# Send Color and Brightness to fit-statUSB
$port -> write("$random_color\n");
$port -> purge_rx;
$Mem_Use_Label -> configure (-text => 'fit-statUSB Random Color Demo', -background => "$random_color");
}
Conclusions
fit-statUSB can be used for fun and entertaining creations.
fit-statUSB: Random Color Generator
programmable multi-color LED that plugs into a USB port
-
- Posts: 106
- Joined: Mon May 28, 2012 3:25 pm
Jump to
- Announcements
- ↳ Read me first
- ↳ News
- ↳ Ordering
- Tensor-PC
- ↳ General Tensor-PC questions
- ↳ Tensor-PC Hardware
- ↳ Tensor-PC Software
- fitlet3
- ↳ General fitlet3 questions
- ↳ fitlet3 hardware
- ↳ fitlet3 software
- ↳ fitlet3 FACET Cards
- Airtop3
- ↳ General Airtop3 questions
- ↳ Airtop3 Hardware
- ↳ Airtop3 Software
- ↳ Airtop3 I3M
- fitlet2 and MBM2
- ↳ General fitlet2 questions
- ↳ fitlet2 hardware
- ↳ fitlet2 software
- ↳ fitlet2 FACET Cards
- ↳ Cool stuff with fitlet2
- Airtop2
- ↳ General Airtop2 questions
- ↳ Airtop2 Software
- ↳ Airtop2 Hardware
- ↳ Airtop2 I3M
- Mature products
- ↳ Airtop
- ↳ General Airtop questions
- ↳ I3M
- ↳ IPC2 (Intense PC2)
- ↳ General IPC2 questions
- ↳ IPC2 availability
- ↳ IPC2 Hardware
- ↳ Linux on IPC2
- ↳ Windows on IPC2
- ↳ Other operating systems on IPC2
- ↳ IPC2 BIOS
- ↳ IPC2 faults and troubleshooting
- ↳ Intense PC and MintBox 2
- ↳ General Intense PC questions
- ↳ Intense PC hardware
- ↳ CPU & Chipset
- ↳ Display interface
- ↳ Memory
- ↳ Storage
- ↳ Ethernet
- ↳ WLAN and miniPCI-e
- ↳ Audio
- ↳ USB
- ↳ Power and heat
- ↳ Linux on Intense PC
- ↳ Linux Mint
- ↳ Other distributions
- ↳ Windows on Intense PC
- ↳ Win7 on Intense PC
- ↳ Win8 on Intense PC
- ↳ Audio
- ↳ Intense PC BIOS
- ↳ Android on Intense PC
- ↳ Intense PC faults and troubleshooting
- ↳ fitlet and MintBox Mini
- ↳ General fitlet questions
- ↳ fitlet performance
- ↳ fitlet hardware
- ↳ Memory
- ↳ Storage
- ↳ Power and heat
- ↳ Mechanical
- ↳ fitlet BIOS
- ↳ Linux on MintBox Mini / Linux on fitlet
- ↳ Windows on fitlet
- ↳ Other operating systems on fitlet
- ↳ FACET Cards
- ↳ fitlet compatible devices
- ↳ Cool stuff with fitlet
- ↳ fitlet faults and troubleshooting
- ↳ fit-PC4
- ↳ General fit-PC4 questions
- ↳ fit-PC4 hardware
- ↳ Windows on fit-PC4
- ↳ Linux on fit-PC4
- ↳ Other operating systems on fit-PC4
- ↳ fit-PC4 BIOS
- ↳ fit-PC4 faults and troubleshooting
- ↳ fit-PC3
- ↳ General fit-PC3 questions
- ↳ fit-PC3 hardware
- ↳ Display interface
- ↳ Storage
- ↳ Audio
- ↳ WLAN and miniPCI-e
- ↳ USB
- ↳ Power and Heat
- ↳ Ethernet
- ↳ Windows on fit-PC3
- ↳ Linux on fit-PC3
- ↳ Other operating systems on fit-PC3
- ↳ fit-PC3 BIOS
- ↳ fit-PC3 accessories
- ↳ Using fit-PC3
- ↳ fit-PC3 faults and troubleshooting
- ↳ fit-PC2
- ↳ General fit-PC2 questions
- ↳ Buying fit-PC2
- ↳ Linux on fit-PC2
- ↳ Linux Mint
- ↳ Ubuntu 9.10
- ↳ Ubuntu 10.04
- ↳ Ubuntu 10.10
- ↳ Ubuntu 11.04
- ↳ Other Linux distributions
- ↳ Ubuntu 8.04
- ↳ Ubuntu 9.04
- ↳ Display driver
- ↳ Multimedia in Linux
- ↳ Multimedia in Mint
- ↳ Windows on fit-PC2
- ↳ Windows 7
- ↳ Windows 7 display driver
- ↳ Audio in Win7
- ↳ Windows XP
- ↳ XP installation
- ↳ Display driver
- ↳ Video playback
- ↳ Audio in XP
- ↳ Other Windows versions
- ↳ Other operating systems on fit-PC2
- ↳ FreeBSD
- ↳ fit-PC2 hardware
- ↳ fit-PC2i hardware
- ↳ Display interface
- ↳ Storage
- ↳ Audio
- ↳ WLAN and miniPCI-e
- ↳ USB
- ↳ Auto-ON
- ↳ Power and Heat
- ↳ Ethernet
- ↳ RTC & System clock
- ↳ fit-PC2 BIOS
- ↳ BIOS updates fit-PC2
- ↳ BIOS updates fit-PC2i
- ↳ fit-PC2 accessories
- ↳ Using fit-PC2
- ↳ HTPC
- ↳ Server
- ↳ Control
- ↳ Verified displays
- ↳ Car PC
- ↳ fit-PC1 questions
- ↳ fit-PC Slim questions
- ↳ uSVR
- ↳ General uSVR questions
- ↳ IPC3
- ↳ General IPC3 questions
- ↳ IPC3 Software
- ↳ IPC3 Hardware
- ↳ FACE modules
- ↳ FACE Modules
- ↳ General FACE Module questions
- Compulab accessories
- ↳ fit-Headless and fit-Headless 4K
- ↳ fit-Uptime
- ↳ fit-statUSB
- ECN/PCN
- ↳ fitlet3 ECN/PCN
- ↳ Tensor-I20 ECN/PCN
- ↳ Tensor-I22 ECN/PCN
- ↳ fitlet2 ECN/PCN
- ↳ Airtop3 ECN/PCN
- ↳ IPC3 ECN
- ↳ fitlet1 ECN
- ↳ IPC2 ECN
- ↳ IPC1 ECN
- ↳ Airtop2 ECN
- ↳ Airtop1 ECN
- ↳ fit-PC4 ECN
- ↳ fit-PC3 ECN
- ↳ fit-PC2 ECN
- ↳ FACE Modules ECN
- ↳ FACET Cards ECN
- Wish list
- ↳ Addressed requests