A spectrometer functions by dispersing incoming light via a prism or a diffraction grating. The dispersed light is then detected by sensors that measure the intensity of light at different wavelengths. This data is used to create a spectrum, which can be analyzed to identify the chemical composition, temperature, density, and motion (through Doppler shift) of the observed object.