This is a side project from my endeavor to program an Arduino Uno wirelessly (over Bluetooth) using a cheap HC06 JY-MCU Blueetooth Module I got from eBay.
In order to kick off the Arduino bootloader and upload a new sketch, you need to reset the Arduino at the right moment, and hold the reset pin “LOW” for the right duration, or else things can go bad.
Eventually I found out a circuit that does exactly what I wanted and, as a bonus, has a cool name: a “monostable multivibrator”. I feel smarter just typing that!
A monostable multivibrator, as the name suggests, has one stable state. For example: the output of the circuit is normally “LOW” and that is its stable state. When triggered by an input pulse, a monostable multivibrator will switch to its unstable state (e.g. switch from an output of “LOW”, to an output of “HIGH”) for a pre-defined period of time. After that it will return to its stable state (back to an output of “LOW”). You can control the duration of that unstable state (in our example the duration of the “HIGH” output pulse) using an RC circuit (a combination of a resistor and a capacitor). Here is a picture of what is happening:
Aha! So…what is this good for? Well, it is kind of a very accurate all-in-one switch and timer. Imagine you want something to run for exactly 2 seconds and then stop, when someone presses a button. Humans are not reliable and so you don’t know how long they will keep the button pressed. A monostable multivibrator will make sure that your process runs for 2 seconds exactly every time someone pushes the button, and then switches off, regardless of how long the button was kept pressed down by the fickle human finger (the duration of the input/trigger pulse).
So how do you build this magical circuit? Well, there is more than one way, but I used a 555 timer IC, a couple of resistors and capacitors. Here is a video with the circuit diagram, background info and of course an LED on a breadboard to show it in action!
For further reading on the Monostable Multivibrator circuit see: Electronics Tutorials
Back to my project of programming an Arduino over Bluetooth. Using this circuit, I can now safely trigger the Arduino reset process from software and rest assured that the Reset pin will be kept LOW long enough for the bootloader to kick in and do its job.
An Arduino digital pin is connected to the input of the 555 timer. The output pin of the monostable multivibratorciruit is now driving the Arduino rest pin (via a transistor connected to ground, to invert the pulse from HIGH to LOW). More details on this coming soon!