driving 8 LEDs over LPT

Hey there,

today i will show you how to control 8 LEDs over the LPT Port… And yes.. i will use the ugly LPT to breadboard cable :)

1. wiring the breadboard:

  • connect the anodes with the 8 data pins (2 – 9) from the LPT Port.
  • connect the cathodes with a suitable Resistor to one of the LPT ground pins (18-25)

PIN-2 — (+) >> Diode >> (-) — Resistor — GND
PIN-3 — (+) >> Diode >> (-) — Resistor — GND
PIN-4 — (+) >> Diode >> (-) — Resistor — GND
PIN-5 — (+) >> Diode >> (-) — Resistor — GND
PIN-6 — (+) >> Diode >> (-) — Resistor — GND
PIN-7 — (+) >> Diode >> (-) — Resistor — GND
PIN-8 — (+) >> Diode >> (-) — Resistor — GND
PIN-9 — (+) >> Diode >> (-) — Resistor — GND

I used LEDs with an integrated Resistor.

Programming the LPT port:

here is my tiny C program ive used for the video. It uses the ppdev kerneldriver. i will release the windows port in a few days ;)

pptest.c

/********************************
pptest

small and simple demoprogram to test
the LPT port.

this code was hacked in 5 minutes
and HANDLES NO ERRORS! 

2012/12/31 by Tino Goehlert (cmdrk33n)

http://cmdrkeen.net

********************************/

#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/ppdev.h>
#include <unistd.h>
#include <stdlib.h>

int parportfd = 0;
unsigned char r_data = 0x00;

unsigned char togglepin(unsigned char pin)
{
	r_data ^= 1 << pin;
	ioctl( parportfd, PPWDATA,&r_data);
	return r_data;
}

unsigned char clearpin(unsigned char pin)
{
	r_data &= ~(1 << pin);
	ioctl( parportfd, PPWDATA,&r_data);
	return r_data;
}

int main()
{
	parportfd = open("/dev/parport0", O_RDWR);
	ioctl( parportfd, PPCLAIM, NULL );
	//
	int repeats=0;
	for(;repeats<=10;repeats++){
		int pin = 0;
		for(pin=0;pin<8;pin++){
			togglepin(pin);
			usleep(50000);
		}

		for(pin=0;pin<8;pin++){
			clearpin(pin);
			usleep(50000);
		}
	}

	ioctl(parportfd,PPRELEASE);
	return 0;
}

pptest running on arch linux X64:

LPT to breadboard cable (the ugly way)

Working with PC ports on a breadboard was an frustrating task for me and i couldn’t find cables with only one pin row.

I will try to build my own breadboard 2 PC cables. I use different methods for each cable to develop a clean and easy solution.

and here is the first one:

LPT to breadboard cable

parts used:

  • pin bar
  • small shrink-on tube
  • old LPT cable
  • soldering equipment

yeah.. maybe this is one of the ugliest solutions. First i have measured every pin and noted the color of the cord, because i used an old LPT cable that can’t be opened. Oh.. and i want to thank my wife for holding the Multimeter on the cord end :D

We need 2 small shrink-on tubes to cut them into small pieces (1,5 cm – 2,0 cm should be enouth). And again.. thank you honey! ;)

Now we have the pin numbers and their colors, 25 pieces of shrink-on tube and our solder iron heating up. Lets start soldering the 25 cords to our pin bar… hmpf!!

I have started with cord 1 on the right end. Do not overheat the pin, the plasic in the middle can melt and loose the pin! You should also trim the cords in the middle because the outer cords need to be longer.

And now say hello to your new (and ugly) LPT cable that you can use on your breadboard!

image

I will provide a better method for an RS232 to breadboard cable this evening.. so stay tuned and thanks for reading! ;)

“WiiCoptr” :D (IR helicopter automatic attitude control)

 

DP:
Amieres built a IR controlled Helicopter with Wiimote using USB IR Toy V1. A camera connected to the laptop tracks the helicopter. Using the USB IR Toy the laptop sends automatic attitude control signals. Setting attitude points is done with Wiimote’s up/down buttons, while nunchuk joystic is used for motion control.

original post on dangerousprototypes.com