3 ms·
IIRC, on a 328 you can turn on external interrupt for an entire port ( 8 pins ) at once. Once the interrupts fires, you detect which pin has changed. This does
by the-dude 9y ago
IIRC, on a 328 you can turn on external interrupt for an entire port ( 8 pins ) at once. Once the interrupts fires, you detect which pin has changed.
This doesn't work for the 32u4 ?
- jononor 9y agoLooking at the datasheet for 32u4, port B does have pin change interrupt. So one could maybe use that. Depending on what pins are exposed on Leonardo board, might need to combine with with external interrupts on pins to get a full 8. A challenge is that the capacitive sensing works by sensing how long it takes. For small capacitance (depends on your sensor pads) and resistor values, this is in the order of tens of clock cycles. That can be challenging to measure with a timer. Several such measurents are summed up to suppress noise. However for bigger sensors with higher capacitance, like for distance sensing, then interrupt-based code makes more sense because the uC would actually wait for a significant time.