synchronizing IR LEDs with transistor inputs

hey! I'm using ~48 QRE1113 reflective IR sensors. I'd like to drive all 48 LEDs at ~1-4% duty cycle and shift in the transistor inputs.

What's an appropriate way to synchronize driving the LEDs ON and reading the transistors?

I'm planning on using the SAMD21 M0. What's the advantage of using the PWM timers vs setting up my own timer using delays; such as

digitalWrite(pin2, HIGH); //mosfet turn ON LEDs
delayMicroseconds(1); //wait for the LEDs to turn ON TBD
digitalWrite (LATCH, LOW);    // pulse the parallel load latch
digitalWrite (LATCH, HIGH);
switchBank1 = SPI.transfer (0);
switchBank2 = SPI.transfer (0);
switchBank3 = SPI.transfer (0);
switchBank4 = SPI.transfer (0);
switchBank5 = SPI.transfer (0);
switchBank6 = SPI.transfer (0);
digitalWrite(pin2, LOW); //turn off LEDs

//do some logic, count things, wait to take another reading

The default PWM frequency is 730hz or 1.37ms. For energy savings and resolution a duty cycle of 1-5% seems a good start. AnalogWrite(PIN1, 1) then gives 1.3ms/256 and keeps the led ON 5.2us or ~4% of the time. But how do I synchronize this activity with the hardware SPI? How to I evaluate the advantages? shfting in using 6 74HC165s.

The power draw of ~48 LEDs with resistors is 1.5watts. A 4% duty cycle brings the average current down to ~20ma... which is nice.

Thanks for the help!

Syncing your measurements to the pwm output pin will probably require the use of an interrupt, and by definition this makes your program more complex and harder to debug.

Yea I was thinking the same thing, there is probably a way to tie an interrupt to the PWM timer. I even thought you could feed the PWM back into the microcontroller on an input pin and use that to trigger the SPI read but that can't be the best way, right?

I feel that when I read about people trying to blink LEDs at specific intervals they always default to the PWM timers.... so I'm curious what the advantages are or if they're are any advantages for this specific application.

Thanks!