What Code Should I Use to Create a Single Pulse Wave on my Arduino Uno?

Hello, 
I am in need of some code for my Arduino Uno. I searched around online for code that can perform pulse width modulation, but nothing I have found completely suits my needs. What kind of code should I use to generate a short blip of voltage which will quickly subside? More details, including what I am using the Arduino for, are shown below.

Upon the press of a tact switch, I need the arduino to emit a single pulse wave with an extremely low pulse width. I am using this as a trigger for a DIY audio project. Specifically, I am using this to trigger an anaolg drum machine circuit I found online. After much experimentation, I have found that triggering the drum circuit with an ordinary square/pulse wave really results in two different sounds: one which is created when voltage is applied and one which is generated when it is taken away. The sound I need is the one created when voltage is taken away, therefore I need a very fast voltage spike which will quickly return to zero voltage. This way, the other unwanted sound is less apparent. 

Most of that last paragraph was extra info, but I figured that I should supply all of the information I have. Any help will be greatly appreciated, as I am totally new to the Arduino and am not sure where to begin in terms of coding. 

Thanks!

sort by: active | newest | oldest

If you want to create a trigger, then you could actually use a digitalWrite function instead of analogWrite. And if you want to make the pulse width very short then you must use a delay function which will make the trigger to zero voltage as soon as the delay terminates. Follow this piece of code for better understanding.

digitalWrite(pin, HIGH);

delay(10);

digitalWrite(pin, LOW);

smaller the delay, shorter will be the width of the generated pulse. Alright?

rah187 (author)  Techovator08194 months ago

Thank you! I think this is the approach I am looking for. Now I just need to figure out how to make the arduino do this at the press of a tact switch. If I can do this, I will have a complete drum synth trigger.

You're Welcome

Downunder35m4 months ago

You can't create a pulse that goes away quickly without first creating the pulse.

rah187 (author)  Downunder35m4 months ago

I am not trying to make a pulse wave which goes away quickly without creating the pulse; that makes no sense. Instead, I am trying to make a single pulse with a very narrow pulse width. The pulse would have a voltage spike followed by a period of time where the output stays "high". This period of time would be extremely short, and afterwards the output would become "low" again. The reason that the pulse needs to be so narrow is that a wide pulse width would create two discernible sounds when fed through the synthesis circuit. By making the pulse width as narrow as possible, the unwanted sound would still be present, although it would be much less apparent because it would blend in with the sound that I want (that's the idea, anyway).

rickharris rah1874 months ago

Think about this, In your current program what defines the width of the pulse? A simple high followed by a low command will do what you want BUT you will be limited by the speed of the processor as to how narrow the pulse will be. as well as how often you can repeat it.

You need to look for how to turn an output on and off.