reading bulb states and calculating position number