Here' s an melody player with Atmega16. The command "Sound Speaker" is used to generate sound. This is the inbuilt command in Bascom AVR.

Circuit Diagram

Download

Bascom code