user27804: I want to overclock my Game Boy Advance SP. It has a built-in 4 MHz crystal, and I was able to temporarily replace it with an 8 MHz crystal to see if I was able to overclock it, which I was :).
However I'm wondering if it's possible to emulate/simulate a crystal using an Arduino? Like instead of a crystal soldered to the Game Boy, two output pins from the Arduino? If not, is there a such thing as a variable oscillator? Like a crystal with a potentiometer to change the frequency when the potentiometer is adjusted?

user10794: You want to use the Uno? You can set up a timer to output varying frequencies and output them on a pin. I have a page about timers which might help. The fastest you can get with a 16 MHz processor is 8 MHz output however you can get other frequencies by changing the timer parameters.
The ATtiny85 can output higher frequencies if you use the PLL clock option, I think you can then adjust the resulting frequency.

If not, is there a such thing as a variable oscillator?

Adafruit make a Clock Generator Breakout Board - 8KHz to 160MHz. You connect that via I2C to your Arduino and then program assorted frequencies as a clock output. That uses the Si5351A clock generator chip.

Example code to output 8 MHz on a Uno or Mega2560:
#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

To output 4 MHz change OCR1A to 1 rather than 0.

user4143: A crystal oscillator connection to a microcontroller typically consists of two pins - an output "driving" pin, and an input "amplifying" pin. The crystal sits between the two pins (basically between the input and the output of the amplifier) and the amplifier oscillates at the frequency of the crystal.
In general you can bypass the crystal itself and just provide a clock signal on the input pin (often labelled OSC1 or OSCI) and ignore the output pin since it isn't needed to drive a crystal.
Some microcontrollers provide a special "EC" mode (External Clock) which disables the amplifier and just expects a clock signal.

27804: <p>I want to overclock my <a href="https://en.wikipedia.org/wiki/Game_Boy_Advance_SP" rel="nofollow noreferrer">Game Boy Advance SP</a>. It has a built-in 4&nbsp;MHz crystal, and I was able to temporarily replace it with an 8&nbsp;MHz crystal to see if I was able to overclock it, which I was :).</p>

<p>However I'm wondering if it's possible to emulate/simulate a crystal using an Arduino? Like instead of a crystal soldered to the Game Boy, two output pins from the Arduino? If not, is there a such thing as a variable oscillator? Like a crystal with a potentiometer to change the frequency when the potentiometer is adjusted?</p>
 10794: <p>You want to use the Uno? You can set up a timer to output varying frequencies and output them on a pin. I have <a href="http://www.gammon.com.au/timers" rel="nofollow">a page about timers</a> which might help. The fastest you can get with a 16 MHz processor is 8 MHz output however you can get other frequencies by changing the timer parameters.</p>

<p>The ATtiny85 can output higher frequencies if you use the PLL clock option, I think you can then adjust the resulting frequency.</p>

<blockquote>
  <p>If not, is there a such thing as a variable oscillator?</p>
</blockquote>

<p>Adafruit make a <a href="https://www.adafruit.com/products/2045" rel="nofollow">Clock Generator Breakout Board - 8KHz to 160MHz</a>. You connect that via I2C to your Arduino and then program assorted frequencies as a clock output. That uses the Si5351A clock generator chip.</p>

<hr>

<p>Example code to output 8 MHz on a Uno or Mega2560:</p>

<pre class="lang-c++ prettyprint-override"><code>#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
</code></pre>

<p>To output 4 MHz change OCR1A to 1 rather than 0.</p>
 4143: <p>A crystal oscillator connection to a microcontroller typically consists of two pins - an output "driving" pin, and an input "amplifying" pin. The crystal sits between the two pins (basically between the input and the output of the amplifier) and the amplifier oscillates at the frequency of the crystal.</p>

<p>In general you can bypass the crystal itself and just provide a clock signal on the input pin (often labelled OSC1 or OSCI) and ignore the output pin since it isn't needed to drive a crystal.</p>

<p>Some microcontrollers provide a special "EC" mode (External Clock) which disables the amplifier and just expects a clock signal.</p>
