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!

