We are using and Arduino UNO and we're trying to figure out what the sample speed of the digital read sensor is? How many hertz can the arduino handle?
Thanks
We are using and Arduino UNO and we're trying to figure out what the sample speed of the digital read sensor is? How many hertz can the arduino handle?
Thanks
Print micros() before the 'read' then print micros after the 'read', subtract.
You can use port manipulation to speed up a read.
.
byte X=PIND;Takes about three machine cycles (62.5 nanoseconds each).
What is it you're trying to read?
You can read a port and put into an array also.
For example, start reading when a pin goes low:
int x;
if ((PINB & 0b00000001) == 0){ // D8 low, start reading
for (x=0; x<1000; x=x+1){ // take 1000 samples
dataArray[x] = PIND; // read port D
}
}
The for loop adds some time to increment x and check it.
If you want it really fast, do a bunch of discrete reads:
x=0;
if ((PINB & 0b00000001) == 0){ // D8 low, start reading
dataArray[x] = PIND; // read port D
dataArray[1] = PIND;
dataArray[2] = PIND;
:
:
dataArray[998] = PIND;
dataArray[999] = PIND;
}