From: "Vernon Graner" > > At first I though about polling inputs in a tight loop, but that would > allow the possibility of one input being detected as first when the > other one was actually first (depending on the loop position). > Haven't tried it, Vern, but I think you had the right idea: poll in a tight loop. To get around the problem of seeing one pin change before the other, just examine them both at once. Again, this is not tested code, but something very like the code below should work. The important points are in this loop: DO TriggerValue=INA&%00000011 LOOP UNTIL 0<>TriggerValue First, it captures the state of both input pins in the same instruction. (This is not the same as "simultaneously".) Second, the pin values are moved into a declared variable that will not change before we have time to examine it in code that follows the loop. This code cannot resolve ties that occur within the short time interval of that loop, but a millisecond is surely close enough for a Raingutter Regatta, isn't it? Are you limiting bowsprit lengths? Good luck, Gary '{$STAMP BS2} '{$PBASIC 2.5} ' -----[ The Finish Line ]------------------------------------------------------ FlagHigh CON 1000 ' Or whatever pulse width causes your servo ' to raise the checkered flag FlagLow CON 250 ' Again, substitute the calibrated pulse width ' for the flag low position in your servo ' -----[ Variables ]------------------------------------------------------------ TriggerValue VAR Byte cntI VAR Nib ' -----[ Main Code ]------------------------------------------------------------ Main: OUTS=%1111111111111111 'Preset high as a general practice to avoid problems DIRS=%1111111111111100 'All outputs except the two trigger pins. 'At this point Pin0 and Pin1 are inputs, Pin2 is an output GOSUB RaiseTheFlag DO TriggerValue=INA&%00000011 LOOP UNTIL 0<>TriggerValue GOSUB LowerTheFlag IF 1=IN0 THEN DEBUG "The RIGHT boat wins!",CR ELSEIF 1=IN1 THEN DEBUG "The LEFT boat wins!",CR ELSE DEBUG "Gary's code blew it somehow!",CR ENDIF END RaiseTheFlag: FOR cntI=1 TO 30 PULSOUT 2,FlagHigh PAUSE 20 NEXT RETURN LowerTheFlag: FOR cntI=1 TO 30 PULSOUT 2,FlagLow PAUSE 20 NEXT RETURN [Non-text portions of this message have been removed] IF (1=TriggerValue) THEN DEBUG "The RIGHT boat wins!",CR ELSEIF (2=TriggerValue) THEN DEBUG "The LEFT boat wins!",CR ELSEIF (3=TriggerValue) THEN DEBUG "We have a tie!",CR ELSE DEBUG "Gary's code blew it somehow!",CR ENDIF Or using one of the features of PBasic 2.5: SELECT TriggerValue CASE =1 DEBUG "Left boat wins.",cr CASE =2 DEBUG "Right boat wins.",CR CASE =3 DEBUG "We have a tie!",CR ENDSELECT Just for the record,