Maximum frequency of digital signal in Arduino Uno?
Yes, use the hardware timers.
You can achieve 8 MHz.
Example sketch which outputs 8 MHz on pin 9 on a Uno:
#ifdef __AVR_ATmega2560__
const byte CLOCKOUT = 11; // Mega 2560
#else
const byte CLOCKOUT = 9; // Uno, Duemilanove, etc.
#endif
void setup ()
{
// set up 8 MHz timer on CLOCKOUT (OC1A)
pinMode (CLOCKOUT, OUTPUT);
// set up Timer 1
TCCR1A = bit (COM1A0); // toggle OC1A on Compare Match
TCCR1B = bit (WGM12) | bit (CS10); // CTC, no prescaling
OCR1A = 0; // output every cycle
} // end of setup
void loop ()
{
// whatever
} // end of loop
If you change OCR1A you can get lower frequencies. If you change the prescaler you can get lower frequencies again.
See my page about timers for more details.
Also, don't forget that there are alternative methods of toggling outputs.
You can use PORTS to do the job.
Here's a good example. And another here.
And this code is the idea behind it:
void setup()
{
DDRD = B11111111; // set PORTD (digital 7~0) to outputs
}
void loop()
{
PORTD = B11111111; // set PORTD pins (digital 7~0) high
PORTD = B00000000; // set PORTD pins (digital 7~0) low
}
P.S. Don't forget that the port numbering is in reference to the chip pins and not the Arduino pins/legs.