The other wire might be for the rotary switch normally open and closed positions.
I found code I did if it helps. This was to time dialling zero (ten) to calibrate a dial.
The LED should land int he middle, but most dials are a little off.
It happens to know the number dialled too, though the hardware wasn’t for displaying it.
https://www.youtube.com/watch?v=iJGvLOB53C8
'
'
'************************************************* **********************************
'* *
'*
[email protected] *
'* Brek Martin 2013-14 *
'************************************************* **********************************
'
'
DEFINE OSC 20 ' but we are really using 8 MHz
DEFINE NO_CLRWDT ' watchdog is cleared manually
LCD_DATAUS CON 50 ' LCD timing
LCD_COMMANDUS CON 2000 '
'
'INTCON.4 = 1 'enable portb.0 interrupt
'OPTION_REG.6 = 0 'interrupt on falling edge of portb.0
'
'
INCLUDE "Elapsed.bas" '
'
'
'
' execution time!
'
CMCON = 7 ' set portb to digital
trisb.7 = 0 ' set LED outputs
trisb.6 = 0 '
trisb.5 = 0 '
trisb.4 = 0 '
trisb.3 = 0 '
trisb.2 = 0 '
trisb.1 = 0 '
trisb.0 = 1 ' set rotary dial switch input (pulse)
trisa.1 = 1 ' set rotary dial switch input (home)
'
@ clrwdt ; clear watchdog timer manually
'
flashrate var byte
timea var byte
index var byte ' declare values for LED test startup
indexb var byte
bpattern var byte
dialcount var byte
'
oldlast var byte
'
errstart:
'
@ clrwdt ; clear watchdog
bpattern = %00000001
dialcount = 0
flashrate = 8
timea = 64
'
FOR indexb = 0 TO 6 ' fancy led test startup
FOR index = 0 TO 6
@ rlf _bpattern
portb = bpattern
pause flashrate
NEXT index
FOR index = 0 TO 6
@ rrf _bpattern
portb = bpattern
pause flashrate
NEXT index
flashrate = flashrate - 1
NEXT indexb
portb = 0
'
@ clrwdt ; clear watchdog timer manually
'
extint = 0 'reset external variables
freq = 0
ticcnt = 0
'
ready var bit 'declare internal variables
ready = 0
counting var bit
counting = 0
thetime var byte
thetime = 0
'
lasta var byte' 'bit to check for last rising edge
lasta = 0
'
'
Gosub ResetTime 'Reset Time 00:00:00
'
'
'
cycle: ' main routine - 3D Cube user program
@ clrwdt ; clear watchdog timer manually
'
'
IF porta.1 = 1 && counting = 0 THEN
portb = %11111110 ' dial not home indicator
ready = 1 ' set ready to count time status
thetime = 0
bpattern = 0
'
ELSE
'
IF counting = 1 THEN
'
IF portb.0 = 0 THEN
portb = %11111110 ' flash LEDs on for break
pauseus 50
portb = 0
ELSE
portb = 0 ' flash LEDs off for make
ENDIF
'
ELSE
portb = 0
ENDIF
ENDIF
'
'
IF ready = 1 THEN ' check ready to count status
IF portb.0 = 0 THEN ' look for first falling edge
gosub StartTimer 'start clock timer
thetime = 0
dialcount = 0
timea = 64
counting = 1
ready = 0 ' lock routine
ENDIF
ENDIF
'
'
IF counting = 1 THEN ' check counting and dial at home position
'
IF portb.0 = 1 && lasta > 3 THEN ' look for last rising edge otherwise is overwritten
thetime = Seconds*100
thetime = thetime + Ticks
ENDIF
'
oldlast = lasta
'
IF portb.0 = 0 THEN ' dial switch debounce in software
lasta = lasta + 1
ELSE
lasta = 0
ENDIF
'
IF lasta < oldlast THEN ' increment dial pulse counter
dialcount = dialcount + 1
ENDIF
'
IF porta.1 = 0 THEN
gosub StopTimer
counting = 0
'
timea = 10
'
IF dialcount < 10 THEN ' check that zero was dialed
goto errstart ' or error condition
ENDIF
'
Gosub ResetTime 'Reset Time 00:00:00
ENDIF
ENDIF
'
'
'
'
IF thetime > timea && thetime < 75 THEN ' LED time display
bpattern = %00000010 ' dial too fast
ENDIF
IF thetime > 74 && thetime < 85 THEN
bpattern = %00000100
ENDIF
IF thetime > 84 && thetime < 95 THEN
bpattern = %00001000
ENDIF
IF thetime > 94 && thetime < 105 THEN
bpattern = %00010000 ' ideal time
ENDIF
IF thetime > 104 && thetime < 115 THEN
bpattern = %00100000
ENDIF
IF thetime > 114 && thetime < 125 THEN
bpattern = %01000000
ENDIF
IF thetime > 124 THEN
bpattern = %10000000 ' dial too slow
ENDIF
'
portb = bpattern
pauseus 500
portb = 0
'
'
goto cycle ' end main routine - do the next cycle
'
'