' Servo Pot Control w/ LCD Readout and Bidrectional LED ' {$STAMP BS2} ' {$PBASIC 2.5} DEBUG "Program Running!", CR time VAR WORD ' time reading from pot prevTime VAR WORD ' previous reading index VAR NIB OUTH = %00000000 DIRH = %00000111 OUTL = %00000000 DIRL = %11111000 DO prevTime = time ' Store previous time reading HIGH 1 ' Read pot using RCTIME PAUSE 40 RCTIME 1, 1, time time = 20 * (time) ' Scale pot, match servo range IF ( time > prevTime ) THEN ' increased, pot turned CCW HIGH 13 ' Bi-color LED red LOW 12 ELSEIF ( time < prevTime ) THEN ' value decreased, pot turned CW LOW 13 ' Bi-color LED green HIGH 12 ELSE ' Servo holding position LOW 13 ' LED off LOW 12 ENDIF LOOKDOWN time, <= [20, 100, 200, 300, 400, 500, 600, 750, 900, 1050, 1200], index LOOKUP index, [ %00000111, %00000100, %00000110, %00000110, %00000101, %00000011, %00000011, %00000110, %00000111, %00000111 ], OUTH LOOKUP index, [ %00111000, %00100000, %10011000, %10110000, %10100000, %10110000, %10111000, %00100000, %10111000, %10110000 ], OUTL DEBUG DEC5 time, CR PULSOUT 14, time LOOP