The software for the project is mainly based around the sensor interrupt.  It is important that this interrupt continues to run beyond other processes to ensure that the current time is always updated.  When the reference point on the disk crosses the sensor, an interrupt is triggered.  We expect this interrupt sequence to run every 8.33ms since the hard drive is spinning at 7200 RPMs.  Every time it is triggered, each of the three LED colors are given a value indicating how long to delay the flash of the LED and then they are written to the LED memory mapped location.  The longer the flash of the LED is delayed, the further around the clock the hand will show up.  A timer also starts during this time and masks out any interrupt for 7ms to ensure that any noise can’t cause false interrupts.  Depending on how many times the interrupt has triggered, the delay value for each hand is incremented accordingly.
                
                
During every interrupt sequence, the current status of the NES controller is read through its memory mapped location.  If the A button is held, the time will stop running and allow the user to set the current time.  By holding up or down while A is held, the minute hand delay value is incremented at a very fast rate and then written to the LED memory mapped location.  By pressing left or right while A is held increments or decrements the minute hand by minute intervals and then writes these new delay values to the LED memory.
                
                
If the B button is held, the time will continue to increment, but the alarm time is written to the LEDs instead of the current time.  Pressing a direction on the D-pad while B is held will adjust the alarm time in the same way that the actual time is set.  When the delay values of the current time match the delay values of the alarm time, a global alarm register is set.  This indicates whether or not to run the alarm sequence in software.
                
                
The LCD display is updated by the software.  One character on the display is updated every interrupt.  When the time is displayed on the hard drive, the reference delay values that the hardware uses to calculate when to flash the LED lights is displayed on the screen.  These values are updated in real time.  When an alarm is triggered, the software outputs a different set of characters that correspond to a math problem that must be solved in order to turn off the alarm.  The keypad is polled during an alarm to see if the correct keypad button is pressed.