Site map :

Various stuff
Rotation sensor
Security device
The Robot pages
Lego Ants
Robotarm v1.0
Robotarm v3.0
Tutorial 1
Tutorial 2
Physics of Lego
Measuring strength
Combining motors
Stepper motors
Lego ratchet
Electronic ratchet
1-to-2 multiplexor
2-to-7 multiplexor
RCX Mindstorms
Survey of RCX programming
The famous machines
Turing machine
New Page 1
References and links

Last upgrade to the site:
august 10th, 2002.

There has been 

access to my Lego pages since creation.

This is an unofficial LEGO® web site.
LEGO® is a trademark of the LEGO® Group of companies which does not sponsor, authorize or endorse this site.
You can visit the official LEGO website at:

Copyright 1996, 2000, Denis Cousineau


1. Making a computer controlled robotic arm

Robot Programming page

This page present programs working in Windows 3.11

The main program is a DLL (dynamic library link) that contains functions that can be called using any programming language, as Visual Basic, Visual C, or Turbo Pascal. It contains routines that controls the parallel port. It can be initialized for a specific LPT port, if you have more than one (we recommend that you buy a cheap parallel port card –or even a cheap computer– while making tests, just in case...).

It can control as many as 7 motors, and can detect as many as 8 sensors through on/off switch connected to the port. You can also change the direction of the motors, but they will all turn in the same direction.

Those programs are fully functional, but the parallel port, since it outputs 5 volts, 20 mA, cannot be used directly to control a Lego motor. You need a controller that amplifies the signal to 9 volts, ~600 mA in order to run Lego motors.

Of the 25-pins parallel cable:
Pins 2 through 8 must be connected to motors 1 to 7 (in that order).
Pins 1, 14, 16, 15, 13, 12, 10, 11 detect sensors 1 to 8.
Pin 9 control the direction of motion of the motors.

You can download:

The dynamic library link (DLL):

LEGO.dll: the library It must be placed in the C:\WINDOWS directory in order to work.

LEGO.pas: the source code contains the description of the library, written in Turbo-Pascal for Windows

A test program using straight text output:

UNITLEGO.pas: needed for using the DLL in a Turbo-Pascal program

TEST.pas: a short test program

TEST.exe: the compiled program In case you do not have a turbo-Pascal compiler, with the dll and this executable, you can make tests. Download this file in, say, the directory C:\TEMP. Then, in the Program Manager, choose File: Run, and type in C:\TEMP\TEST-PAS, ok. (You need the DLL)

A Visual-Basic graphic interface

LEGO-VB.MAK The project file for visual-basic v3.0

LEGO-VB.FRM Description of the main window

LEGO-VB.EXE An executable version of the program, in case you do not have the visual-basic software. Download this file in, say, the directory C:\TEMP. Then, in the Program Manager, choose File: Run, and type in C:\TEMP\lego-vb, ok. (you need the DLL)

Of course, I may not be held responsible for any damage that could be caused by these programs

For a test:

Test of the motor: You can use any voltmeter, and measure the current on pins 2 through 9 by placing the + tip on the pin, and the – pin on the metallic plug of the parallel cable. Test of the sensor: Use a 1 K Ohms resistor, put one tip on the metallic plug of the cable and the other tip on one of the sensor pin (1, 14, 16, 15, 13, 12, 11, 10). The resistor is to avoid power surge to the computer that could damage it.