Arduino LCD Keypad

I have an Arduino LCD Keypad Shield V1.1 connected to an Arduino Duemilanove. I am trying to produce a square wave audio frequency of 1-500 hertz. I want the LCD to display the current output in Hz and be able to control the output frequency using the push buttons.

Is this possible?


I am having difficulty figuring out how to produce a square wave of 1 - 500 Hz. Will i need a square wave generator circuit? Or can the microcontroller do this with the software?

This is a lump of code I lifted off this forum, it produces a 50% square wave at 2048 Hz for 3 seconds. Butchering the for loop and the delayMicroseconds lines should give you what you want.

for (long i = 0; i < 2048 * 3; i++ )
    // 1 / 2048Hz = 488uS, or 244uS high and 244uS low to create 50% duty cycle
    digitalWrite(buzzPin, HIGH);
    digitalWrite(buzzPin, LOW);

Sound generation ideas are here, or do a search of the Forum.