Authoring sensor-based interactions by demonstration with direct manipulation and pattern recognition