How to output a square wave clock in the MHz range

Nano can provide square signal at half of its main clock so it is 8MHz.

Like this:

void setup()
{
// ...
	pinMode(9, OUTPUT);

	OCR1A  = 0;
	ICR1   = 1;
	TCCR1A = _BV(WGM11) | _BV(COM1A1);				
	TCCR1B = _BV(WGM13) | _BV(WGM12) |_BV(CS10);
// ...
}

1 Like