First initialize pins before starting thread