New sensor works as programmable switch