Yes, a bad camshaft position sensor will in most cases throw a code, and it may also cause your check engine light to come on. However, that doesn't necessarily mean that the sensor itself is bad. There could be an issue with the wiring between the sensor and the ECM, or there could be a problem with the way the ECM interprets signals from the sensor.