Electronically I am driving it correctly.. its actually only driving an npn transistor..

Somehow my program is restarting when I introduce an input.