Bubble counter problems using a teensy for brewing need a little help please.

I need it to continue to check for co2 bubbles to pass through the photogate so I want it to always be checking for one if possible, and for the led to blink every time a bubble passes through the gate. Oh also I need it to output the information somewhere else, in class I was able to get it to output the readings or results to note pad. That is what I am talking about for a external editor? How can I fix the code so that it works in this fashion? I've been trying to figure it out but I am not well versed enough to fix it on my own. I'm sorry if I'm confusing I'm trying my best to explain, but please help me if you can. Thank you.