Laser Harp-Code Snippet

This snippet of code reads the pins on PORTD. If a pin on PORTD is high, “data” will be larger than 0 and will get stuck in the while loop until the pins on PORTD are low again.  Before entering the loop, global interrupts are enabled which allows the interrupt that generates the tone to be called. Then after all pins on PORTD are low, global interrupts are disabled and the program continues. This is used so that a constant tone will be played for however long a laser is blocked.