Measuring wavelength of light with a diffraction grating