Okay, I need some help with debugging. Here are my three programs:
Arduino sketch
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
LiquidCrystal lcd(13, 12, 2, 3, 4, 5, 6, 7, 8, 9, 10);
int Pin11=11;
void setup()
{
Serial.begin(9600);
}
void loop()
{
char ch = Serial.read();
switch(ch)
{
case '0':
lcd.write('?c0?f?B00');
digitalWrite(Pin11, LOW);
break;
case '1':
digitalWrite(Pin11, HIGH);
lcd.write('!!!!!!!!!!!!!!!!!!!!');
lcd.write(' Intruder?n');
lcd.write(' Beware?n');
lcd.write('!!!!!!!!!!!!!!!!!!!!');
lcd.write('?BFF');
delay(500);
lcd.write('?B00');
delay(500);
lcd.write('?BFF');
delay(1000);
break;
}
}
LIB0 (Perl script to output 0s)
#!/usr/bin/perl -w
### Keep in mind that we need
### to sleep a lot so that the
### LCD/Arduino can keep up!
use POSIX qw(setsid);
use Time::HiRes qw(usleep);
chdir '/' or die "Can't chdir to /: $!";
umask 0;
#open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
#open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!";
#open STDERR, '>/dev/null' or die "Can't write to /dev/null: $!";
defined(my $pid = fork) or die "Can't fork: $!";
exit if $pid;
setsid or die "Can't start a new session: $!";
use Device::SerialPort;
my $port = Device::SerialPort->new("/dev/ttyUSB0");
$port->databits(8);
$port->baudrate(9600);
$port->parity("none");
$port->stopbits(1);
while(1)
{
my $return0=$port->write("0");
usleep(100000);
my $return1=$port->write("0");
usleep(100000);
my $return2=$port->write("0");
usleep(100000);
}
LIB1 (Perl script to output 1s)
#!/usr/bin/perl -w
### Keep in mind that we need
### to sleep a lot so that the
### LCD/Arduino can keep up!
use POSIX qw(setsid);
use Time::HiRes qw(usleep);
chdir '/' or die "Can't chdir to /: $!";
umask 0;
#open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
#open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!";
#open STDERR, '>/dev/null' or die "Can't write to /dev/null: $!";
defined(my $pid = fork) or die "Can't fork: $!";
exit if $pid;
setsid or die "Can't start a new session: $!";
use Device::SerialPort;
my $port = Device::SerialPort->new("/dev/ttyUSB0");
$port->databits(8);
$port->baudrate(9600);
$port->parity("none");
$port->stopbits(1);
while(1)
{
my $return0=$port->write("1");
usleep(100000);
my $return1=$port->write("1");
usleep(100000);
my $return2=$port->write("1");
usleep(100000);
}
I plug in the Arduino, and the LCD is cleared with full backlight and the LED off. I run LIB1 and the LED turns on, and the LCD screen rapidly fills with the number 1 for each character on the screen. So, I unplug the Arduino and kill the script. Then, I run the LIB0 script. The same thing happens, (LED on, screen fills,) except that the screen is filled with the 0s instead of 1s.
Edit: I had the LED in an incorrect pin. I corrected that problem, and the LED still comes on, but it is very dim, especially compared to what it was when it was in the wrong spot.