A method of controlling operation of a mechanism, preferably a dispenser, having a removable component comprises measuring electromagnetic radiation passing through a waveguide carrying at least in part on the removable component and permitting operation of the mechanism only when the measured electromagnetic radiation corresponds with one or more pre-selected parameters. Preferably, the method involves directing emitted electromagnetic radiation with pre-selected input parameters selected from a plurality of input parameters.