Esplora as a controller while doing other things

I want to use an Esplora in order to make a controller that makes a game that I'm developing interact with the outside world. I created a code for a low health alarm, but I can't seem to make it work as a controller (the way it does out of the box) at the same time. What code can I use in order to achive this?

What code can I use in order to achive this?

It isn't at all clear what "this" is. What have you tried? What did the code actually do? What did you want it to do?