By "pinRead()" do you mean "digitalRead()"? I read that digitalRead() takes about 56 instruction cycles. The Arduino UNO (and most other Arduinos) do 16 instruction cycles per microsecond so that would take 3.5 microseconds (about 286000 reads per second). You can read 20 pins about 14000 times per second.
If you need faster reads you can use direct port manipulation.
Wow...that is fast! I had no idea it could read pins that fast. So 20 pin reads in the main loop is fast enough to keep them in the main loop and not have to use interrupts. Thanks...
johnwasser:
By "pinRead()" do you mean "digitalRead()"? I read that digitalRead() takes about 56 instruction cycles.
Rather, it is between 60 and 80 (PWM capable output) clock cycles.
There are two other faster solutions:
digitalReadFast () functions which take about 30 clock cycles.
Direct reading of PINX register (X = A, B, C, D: see datasheet microcontroler) that take only 8 clock cycles.
With 16 MHz Xtal one clock cycle = 62.5 ns