problem with pulseIn() (waits too much time)


I am doing a program for reading pulses that i am receiving from the digital input 3 of arduino UNO. So i want the program to move a step motor 28byj-48 and send data and time to the serial port. The problem is that with the function pulseIn, it waits too much time for read the pulse and then the program doesn’t work properly. I thought about using interruptions but then the function millis() doesn’t work so… i’m lost. Anyone has some idea to how can I do it properly? Thank you a lot.

I’m reciving a pulse of (10011) and (10010) for turning the step motor in one direction or the other. I have attached an image of the time of the pulses and the inital pulse. Also i have attached my program.

As you will see in the program it has two main parts, the program for the read of the pulse and the guide for the step motor and another part that corresponds to the comunication part, you will see that i am sending data from a analogic input of the arduino and the time that i send this data, that is everu 10 ms.


Bernat Serra Casamitjana

pulse_receiver.ino (4.51 KB)


First look at changing the default timeout for pulseIn().