Let´s start with a fun video ( with fun music)
Hello ! I made this fake stun gun that simulates the lights and the sound of sparking.
Inside the device there is a PIC microncontroler ( 12F629) that generate two signals.
One of them is 20 Hz / 50% DUTY square wave for make blink the two Leds simultaneously.
The other signal es a 20 Hz / 5% DUTY that excites the gate of a MOSFET transistor.
In this way short pulses of current are sent to the speaker making it sound like a taser. I design a simple case in TinkerCAD and printed some stikers to give it a good appearance.
Step 2: The Circuit
The 7805 provide 5V to the microcontroler.
The microcontroler directly drives the two LEDs.
R4 is a pull-up resistor connected to GPIO4 pin ( GPIO4 is the pin is set to 5V by software). This pull-up resistor put a high level in the input pin when the pushbutton is not pressed.
When the pushbutton is pressed, the microcontroller generate 20 Hz square waves in the GP0, GP2, and GP5 output pins. As I explanied in the intro :The waveform on pin GP5 has a 5% DUTY CYCLE and the waveforms on pins GP0 and GP2 has a 50% DUTY CYCLE.
I decided to use a 5% for the speaker signal duty cycle because I think it's the one that generates a more realistic sound
For more volume, we can use a bigger speaker or use a battery with a higher voltage.