RTC Light Timer Example?

You may want to look into this

You don't need to use System.sleep() but can do anything you want in that true or false branch.