Tonight I ran some tests on the Arduino Uno's input/output pins.
I hooked a single Arduino pin to an oscilloscope and measured the frequency at which the Arduino could toggle the pin from high to low. I used the following code:
for (int i = 0; i < 10; i++)
float test = 13/.0777;
test = test * 1.030232;
for (long int t = 0; t < 10000000; t++)
int x = 3;
float y = x / 2.3;
The frequency came out to be about 120KHz. As a comparison, I re-ran the code without loop in between the digitalWrite calls.
Without any thing else happening, I found that the Arduino was able to toggle the pins at the same frequency (120KHz).
To test the reading rate, I setup a 50% duty cycle pulse train at varying frequencies and then attempted to detect the rising edge using the following code:
unsigned long w = 500;
_t = millis();
while ((millis()-t) < w)
if (PIND & (1<<7)) state = HIGH;
else state = LOW;
if (state == HIGH && _state == LOW)
_state = state;
Serial.print("Time during sensing: ");
Serial.print("Number detected: ");
Now, as I vary the frequency of the pulse train I compared the number of pulses that should have been sent to the arduino along with the number the arduino reportedly detected. Up to 40KHz the numbers were usually the same (within 1 or 2) but past 40KHz, the Arduino couldn't keep up. At 50KHz the Arduino only reported detecting about 24000 pulses during a half second detection cycle. That is a pretty hefty loss if you ask me.
Now, my question is this: Does any one know how, electrically and physically, the Arduino detects when the digital pins are high or low? I still need to do some research on these things and compare the Arduino to other microcontrollers/microprocessors out there, but overall I found the results interesting.
I hope this information helps the community,