PULSIN
Syntax
PULSIN pin, level, variable
Description
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.
Example
'Wait for pin 7 to go high then low.
'Print the number of microseconds pin 7 was high.
PULSIN 7, 1, val
PRINT "Pin 7 pulse high for "; val; " us"
'this example will only work on the ARMstamp
' PULSIN routine -- attach a 10 KHz signal
generator to pin 15
' this uses the > run immediate operator and the . print immediately
operator
>PULSIN 15, 0, x
.x
50
Differences from other BASICs
- no equivalent in Visual BASIC
- Times are measured in microseconds rather than CPU dependent ticks in PBASIC