Example

  FREQOUT Pin, Duration, Freq

Function
Generate square wave for a specified duration.

Quick Facts
  Low Limit High Limit
 Frequency FREQ ÷ 500,000 FREQ ÷ 32

Note: For the greatest possible accuracy, limit high frequency value to FREQ ÷ 512.

Explanation
FREQOUT generates a square wave on an I/O pin. The output pin may be connected as shown in the circuits below for audio use. Other applications include IR LED modulation.

Note that the Duration can be affected by Freq parameter. For example, a frequency of 100 Hz has a period of 10 milliseconds, hence the shortest possible Duration value is 10. Even at this minimum, only one cycle would be produced and this may not be practical or useful.

When driving a Hi-Z speaker (> 40 Ω) or piezo element:

           

When connecting to an audio amplifier:

           


Related instruction: SOUND