Digital Dimmer Circuit -Code

This section of the code is heart of the project. Being able to detect each zero crossings and to interrupt the program appropriately is important. The read on the interrupt pin will be HIGH and drop to LOW when the sine wave crosses zero and rise back up to HIGH. On that rising edge, the program will be interrupted and will jump to the interrupt handler. Within the interrupt handler, the potentiometer analog input will be use to calculate the appropriate delay time before sending a pulse to the driver to allow the current through.