I am working on a project that uses a sparkfun capacitive touchpad as a button to control a light switch. In the firmware loop() i listen to the input from the button and when it’s touched I call a function to turn on the relay, close the circuit and turn on/of the light. I also have a function to turn on/off the light to be called remotely from the cloud. The issue I’m having is that the photon device doesn’t always respond to the cloud call. What’s the best way to write a firmware that uses the loop to listen to input from a pin and at the same time responds to any cloud function call?