Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • you could just watch millis(), and read A0 and A1 when 20 ms elapses ... if you still want to use an interrupt, then set a flag in the ISR ... check the flag in loop() and take readings when flag is set ... both ways are very similar Commented Jan 7, 2021 at 2:08
  • see the BlinkWithoutDelay example and convert it to 'ReadWithoutDelay' Commented Jan 7, 2021 at 6:42
  • 1
    If you need cycle-accurate timings, you can configure the ADC to be triggered by a timer event (not an interrupt, just the event). Then you would use the ADC interrupt to retrieve the result. This requires studying the datasheet and diving into the intricate details of the hardware. If you do not care about sub-millisecond inaccuracies, timing with micros() à la “Blink without delay” will be good enough and way easier. Commented Jan 7, 2021 at 8:10
  • Do the two reading need to be at (almost) the same time, or is it also acceptable to sample a 40Hz, and alternate between A0 and A1? Commented Jan 7, 2021 at 15:31
  • Thanks to all of you for the respond, Commented Jan 8, 2021 at 20:45