1ms is peanuts compared to that though, look at the blink without delay sketch and use micros() instead of millis() so that you get a better grasp at what's going on. using pin registers will be faster than digitalWrite()
On a typical 328P you can use the PIND register to flip a pin. if you put that in a while(true) loop, it will give high frequency (almost 8 MHz)
Hi @npsantini
The arduino UNO, nano, mini, (ATMEGA328) when connected to 5V, has a clock of 16 Mhz (16,000,000 Hz).
It has a cycle of 62.5 peak seconds or 0.0625 microseconds.
As, in simple terms, it executes one instruction per clock cycle, so theoretically it would have a pulse every 2 cycles.
1 cycle turns the LED on and one cycle turns the LED off.
In other words, we would have the LED blinking every 0.125 microseconds.
But as when writing the program other instructions are added, I would say you can get 1 pulse on the LED every microsecond. Or 1MHz.
RV mineirim
PS:
Pretty much any LED available can be operated at far higher blink frequencies than 1 KHz: White LEDs or others which use a secondary phosphor would be the slowest, often topping off in the 1 to 5 MHz region, while standard off-the-shelf primary LEDs (red, blue, green, IR, UV etc) are typically rated at a cut-off frequency of 10 to 50 MHz (sine wave).
Depends...
What kind of LED, particularly how much power?
Not a white LED I hope/assume, because then all bets are off - most white LEDs rely on phosphor coatings that are way slower than what you need.
The higher the power, the more critical the driver circuitry would become.
That's slooooooow for an Arduino and semiconductors. Don't worry about it. Especially if you can get away with using some kind of linear current limiter circuit (e.g. a simple resistor).
How about a PCA9685. That's something like 1.4kHz@ 12 bits, hence something like 0.71ms / 4095 = ca. 173ns shortest pulse width.
As others have indicated, 1 ms is slow in Arduino land.
However if you want to power and LED that requires a driver you have to pay attention to the Arduino output drive limitations. But you can still approach 100's of ns with a larger LED.
Using the hardware timers, you can get even shorter pulses; usually down to about 2 CPU clock cycles. On faster CPUs, such fast signals may not "survive" being output to pins and traveling along wires...
With PIN register probably faster. One instruction for the register, one branch to jump back to the previous instruction, probably worth checking how fast this runs
It was mentioned in the linked discussion. 2.6667 MHz. Remember that toggling a pin is only half a cycle; you have to do it twice... 2 cycles of OUT, 4 cycles of jumps, 2.6667 MHz.