PULSIN -- Obsolete PBASIC routine

  ' PBASIC library, these routines were written for ARMexpress, and included for general reference

#include <PULSE.bas>                                      ' source in /Program Files/Coridium/BASIClib

FUNCTION PULSIN ( pin, level )


Measure an input pulse on pin at level, returning the value to variable.

The IO direction of pin will be set to input.

If pin is already at level when the function is called it will wait to a transition to the opposite level.

The function will wait 1 second for pin to go to level. The length of time is measured in microseconds(us).  The minimum pulse that can be measured is 1 microseconds. If pin does not go to level or remains at level longer than 1 second variable is set to 0.

#include <PULSE.bas>

'Wait for pin 7 to go high then low.
'Print the number of microseconds pin 7 was high.

tim = PULSIN (7, 1)
PRINT "Pin 7 pulse high for "; tim; " us"

Differences from other BASICs

See also