Monostable multivibrator using arduino

Monostable multivibrators can be used for applications such as delay circuits, timers, etc. The circuits like alarms, doorbells, calling bells, flashers, indicators, etc., use the monostable multivibrators, where the device is operated for a short interval of time, after the triggering.

A monostable multivibrator (” one shot multivibrator “) is a multivibrator circuit which has only one stable state. That is, it has a single pulse output which is externally triggered. When an external trigger is received at the trigger pin (“input pin”), the output of the monostable switches to an unstable or quasi-stable state. The output then returns to its stable state after a preset time period.

Monostable multivibrator using arduino

The trigger pulse may be active high or active low. Here in this circuit, we are coding the program, to work for an active high trigger pulse. The triggering is given to the digital pin 2. The trigger pin reads the input and switches the output (digital pin 3) with respect to it. When a positive trigger pulse is received the output switches to a high state from a low state. The output returns to the stable low state after the delay time. The delay value, that is variable ” Time ” in the code, sets the time period of the unstable state or the ON state. In the program, a 500-millisecond delay is set as the time value. So just change the variable to adjust the time period to the desired value.

The interval between each trigger pulse should be greater than the output pulse period. An external oscillator or signal generator also can be used to provide triggering for the multivibrator circuit.

Arduino monostable code

const int trigger = 2; //Pin2 as trigger pin.
const int output =  3; //Pin3 as Output pin.
int Time = 500;        //Preset time delay.

void setup() {
  pinMode(output, OUTPUT);
  pinMode(trigger, INPUT);
}

void loop() {
  if (digitalRead(trigger) == HIGH) {
    digitalWrite(output, HIGH);
    delay(Time);
    digitalWrite(output, LOW);
  }
  else {
    digitalWrite(output, LOW);
  }
}

3 Responses

  1. Trump F-ed My Granny says:

    Very very interezztin’

  2. Clare SNyder says:

    This looks like a good start for a project I am working on – BUT – I need the output to remain high for a period longer thanthe pulse, and retrigger. Here’s the “problem” I am working on. I want a side view camera to come on when I turn my directional flashers on – and to REMAIN ON untill I turn off the flasher. So, the flasher will be a “trigger” to turn on an output, Say the light is ON for 1 second, and off for .75 seconds. I want the output on for 1.5 seconds after the signal stops – so I set the int time= to 2500 (2.5 seconds)? Or do I set it for 1500 – because as long as the input is high the output is also high, and the time delay only comes into play after the input goes low??
    If the input goes high again during the delay does the output remain high – and stay high for another 1500ms after the signal input goes low?
    Can I monitor 2 inputs, with each input controlling an output? – and add logic that if both inputs are high neither output is enabled?? I am assuming I need to have the outputs operate relays to control the cameras – the cameras operate on 12 volts. What current can the arduino supply on the output? Also assuming I need a voltage devider on the input to reduce the 12 volts from the signal lights to 3-5 volts for the trigger?

    • admin says:

      You can set the time for 2.5 seconds. Because once it is triggered it checks the next trigger only after the delay time. The output does not remain high if the input goes high again during the delay.
      If your ON time is not fixed then try the below code. Here once it is triggered, it turns the output ON, and when the trigger input switches to low then it starts to wait a 1.5 seconds before switch off.
      int “state” should initialize as zero.

      if (digitalRead(trigger) == HIGH) {
         digitalWrite(output, HIGH);  
      state = 1; 
      }  
      if (digitalRead(trigger) == LOW && state == 1) {
      delay(Time); // Time 1500
        digitalWrite(output, LOW);
      state = 0;
      }

      Arduino can source or sink 40mA of current per pin. Better to connect the relay using an optocoupler, or use a relay module.
      For 12V input R1 – 2.2k, R2 – 1k which gives a voltage across R2 = 3.75V. (You can use R1 – 1.5k, R2 – 1k gives V = 4.8V; use a Zener across R2 if the voltage is near to 5V in order to avoid any chance of a rise in voltage).

      For 2 Input arrangement; when both inputs are high, do you need to switch off in the next instant or 1.5 delays are allowed for outputs before switch off?

Leave a Reply

Your email address will not be published. Required fields are marked *