James Brown on Mastodon demonstrates making an array of capacitive touch pads on a circuit board. On reading the pads, the typical algorithm of polling was reversed:
The capacitive sensor works by discharging the pad through a resistor and timing how long it takes. Previously I was doing this a few thousand times in a loop and returning the accumulated time. Here I’m doing it the other way round – spending a fixed time in the loop, and counting how many charge / discharge cycles it can do. My aim was to make it easier to tune the sample period, but it turns out noticeably smoother and less noisy this way too.
No comments:
Post a Comment