I am creating a stepper motor controller which has a stepper motor and a LED.

-- When the stepper motor moves, I want to flash the led. To flash the LED, I need to first send a "1" and then a delay of some second, and then a "0".

-- When the motor is moving -- it is in a loop -- I want to flash the led.

--I have created a function for the delay that looks like this



code:--------------------------------------------------------------------------------
For delaytime = 1 to 40000
Next
--------------------------------------------------------------------------------


--Now If I put this code:


code:--------------------------------------------------------------------------------
Do
(Here is all the code to rotate the motor in a loop which is too long so I did not put it here)

portn = PortIn(888)
Call PortOut(888, portn + 16)
delay
Call PortOut(888, portn + 0)
delay
Loop
--------------------------------------------------------------------------------



(PortOut, PortIn are just two functions to send and retrieve a value to and from the parallel port. "16" is just the value which lights the led, and 0 turns the led off. I retrived the value from the parallel port first because I wanted the motor to keep rotating)

The problem is that when the delay is used, it stop the led flashing and also the stepper motor. I want the stepper motor to keep doing its work but the led should stop for the time which is given the loop.

If you dont understand anything then please ask me