Measure the width of a servo pulse

' servopulse_into_D4.bas (Oshonsoft Basic)
' PIC16F877A 20MHz
' simple servo pulse in test - connect RC receiver output channel to D4, pin 27
AllDigital
'this assumes the HD44780 LCD is connected to
' port B as in the palmelectronics EVA board - all defaults assumed
TRISD.4 = 1 'set D4 as input - servo pulses into port D.4
Dim servo_pulse_length As Byte
Lcdinit 'no curser
loop:
ServoIn PORTD.4, servo_pulse_length 'measure the pulse width (1 msec = 100)
Lcdcmdout LcdClear
Lcdout "Servo Pulse in"
Lcdcmdout LcdLine2Home
Lcdout #servo_pulse_length, "0 microsec"
WaitMs 500
Goto loop