In the example you have posted place your code in the "Main" loop. To start try a PAUSE type blink in the Main loop to seehow ot works.