Advertisement
Sound Effects Generator schematic

Funny Micro-Synthesizer

If you are looking for an easy-to-build microcontroller-based sound generator capable of making some amazing, raw synth tones, here is a funny micro-synthesizer/noisebox project to quench the thirst. It’s an extremely simple circuit with an ATmega8 directly generates audio with a little external circuitry. However, since the AVR’s pin outputs are digital, the resulting audio waveforms have only 1 bit of amplitude resolution. In other words, it does pulse waves and nothing else.The control pad consist of eight ordinary push button switches.

The sound generator is a Piezo-Speaker (PZ1). Output from the ATmega8 chip (U1) is fed to PZ1 through a BJT-C1815 (T1). Piezo-Speaker is a speaker that feature a piezo-electric crystal. When we apply a voltage, the crystal distorts, vibrating a plate and producing very loud noise.

ATmega8 Sound Effects Generator Circuit

Sound Effects Generator schematic

Here, an easy and loud way is used to drive the Piezo-Speaker by wiring a 10mH inductor (L1) in parallel with the Piezo-Speaker. The inductance value does not matter to much, something in the range of 10-50mH seems to give the good results with most PiezoSpeakers. Note that the ATmega8 (U1) chip is running on its internal 1MHz oscillator. The electronics also has a 5V linear regulator 7805 (U2), so it can be powered with a standard 9V battery.

For playing different tones, according inputs of PORTD (PD0 to PD7) has to be connected to ground (0V) rail through related push button switches (S1-S8).

prototype board

The firmware is handled in C (using AVR studio 4). The ‘ready-to-use’ Hex File is included here for your convenience. You’ll need a suitable USB asp AVR burner to upload the firmware to the ATmega8 chip.

//Funny Micro-Synthesizer
//An ATmega8-based, 1-bit synthesizer
//ATmega8 Runs on internal RC Oscillator@1MHz
//Tested at TechNode PROTOLABZ on 28 May 2014
//T.K.Hareendran
#include <avr/io.h>
#include <stdlib.h>
uint16_t freq[8]= {3822,3405,3033,2863,2551,2272,2024,1911};
uint8_t button[8];
uint8_t play[8];
uint32_t count[8];
uint8_t general_count;
uint8_t pind_in;
int main(void)
{
   DDRD= 0; //Set PD0 to PD7 as inputs
   PORTD=0xff; //Enable internal pull-up of PD0 to PD7
   DDRB= 0b00000010; //Set PB1 as output
   while(1)
   {
      pind_in=PIND; //Get all bits from PIND register
      general_count+=16;
      for (uint8_t i=0;i<8;i++){
         button[i]=!(pind_in&(1<<i));
         if((button[i])&&(play[i]<255))play[i]++;
         if( (!button[i])&&(!(general_count))&&(play[i]>0))play[i]-- ;
         count[i]+=freq[i];
         if((count[i]&(1<<14))&&(play[i])) {
            PORTB=0b00000010;
         } else {
            PORTB=0;
         }
      }
   }
}

2 Comments

Join the conversation!

Error! Please fill all fields.
Looking for the latest from TI?