The optical characteristics of micro programmable grating based on MEMS were introduced.It is analyzed that the state of the micro programmable grating can be prescribed,and the diffractive emergent light will correspond to the spectra of different target substances.A new method of correlation spectroscopy for methane detection based on micro programmable grating was proposed.The experimental results show that this method can be used to detect various kinds of gas ingredients with high precision.