Register a domain and help support LQ
Go Back > Blogs > peonuser
User Name


Rate this Entry

More details.

Posted 12-07-2011 at 10:45 AM by peonuser
Updated 12-10-2011 at 12:29 AM by peonuser

Basic circuit.

C code to turn pins on and off parallelport light controller. of course the compiled code will called from a bash script.

* Simple parallel port output control program for Linux
* Written and copyright by Tomi Engdahl 1998
* (e-mail:
* The program output the data value to PC parallel port data pins
* (default lpt1 I/O address 0x378). The data values are given as the
* command line parameter to the program. The number can be
* in decimal (0..255) or hexadecimal format (0x00..0xFF).

#include <stdio.h>
#include </usr/include/stdlib.h>
#include <unistd.h>
#include <sys/io.h>

#define base 0x378 /* printer port base address */

main(int argc, char **argv)
int value;

if (argc!=2)
fprintf(stderr, "Error: Wrong number of arguments. This program needs one argument which is number between 0 and 255.\n"), exit(1);
if (sscanf(argv[1],"%i",&value)!=1)
fprintf(stderr, "Error: Parameter is not a number.\n"), exit(1);
if ((value<0) || (value>255))
fprintf(stderr, "Error: Invalid numeric value. The parameter number must be between 0 and 255\n"), exit(1);
if (ioperm(base,1,1))
fprintf(stderr, "Error: Couldn't get the port at %x\n", base), exit(1);

outb((unsigned char)value, base);
#Simple bash script
let nodf=255
declare -i X=$nodf
while true; do
NUM=$[ ( $RANDOM % $X ) + 1 ]
lptout $num
# timing loop here.
Posted in Uncategorized
Views 332 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 08:52 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration