Amorphous hydrogenated carbon nitride (a-CN x :H) films were fabricated via electron cyclotron resonance microwave plasma-enhanced chemical vapor deposition technology using N 2 and C 2 H 2 as nitrogen and carbon sources, respectively. The effects of the N 2 /C 2 H 2 gas flow ratio on the composition, bond structure, scratch resistance, and optical properties of the a-CN x :H films were investigated. X-ray photoluminescence spectroscopy and Raman spectroscopy results indicated that the N/C atomic ratio, carbon 1s sp3/sp2 ratio, and nitrogen 1s sp3/sp2 ratio increased with increasing N 2 /C 2 H 2 gas ratio. Pin-on-disk wear tests conducted with a pin made of ultrahigh-molecular weight polyethylene indicated that all the a-CN x :H films exhibited good scratch resistance; however, rubbing with a stainless-steel ball weakened the wear resistance of the a-CN x :H films as the N 2 /C 2 H 2 gas ratio changed from 5/30 to 30/30. The measured transmittance spectra showed that nitrogen incorporation into the carbon films increased their transmittance in the visible to near-infrared regions. The optical bandgap of the a-CN x :H films was obtained by the Tauc method, which demonstrated that when the N 2 /C 2 H 2 gas flow ratio changed from 0/30 to 30/30, the optical bandgap increased from 1.18 to 1.86 eV. Our results suggest that a-CN x :H films can be used as optical and protective coatings. • Carbon nitride films with varying N content were prepared using ECR-PECVD method. • The N content greatly impacts physical and optical properties of the film. • Fabrication conditions for optimizing hardness and wear resistance were identified. • Carbon nitride films have potential for protective and optical coatings for devices. [ABSTRACT FROM AUTHOR]