AVR®: 10 ms ADC Samples Averaged Over 1 Second

 In this video:

  • Modify a millisecond timer function, fromUpdating PWM duty cycle using a millisecond timer, we create a 10 mS timer.
  • Test the frequency, using the Data Visualizer, by toggling a pin in the timer IRQ.
  • Change ADC auto trigger source to Timer Counter 0 Compare Match A.
  • Create volatile global variables 'accumulator', 'average' and 'samples', using these to calculate an average in the ADC IRQ.
  • Verify that we are now averaging ADC light sensor readings every second.