Astable Multivibrator Using Arduino Code

4 Responses

  1. admin says:

    Astable multivibrator has no external triggering input, only monostable has it.
    If you need to add a triggering input to start the astable vibrator. Use the below code, here once the trigger button is pressed the square wave starts to generates.

    //Add code inside void loop
    if ((digitalRead(trigger) == HIGH) || (state == 1)) {
      //At the beginning Initialize variable state as 0.
      state = 1;
      digitalWrite(output, HIGH);
      delay(Time);
      digitalWrite(output, LOW);
    }
    
  2. shai aga says:

    An Astable Multivibrator has no stable states. It is a two state device which requires no external triggering. The output generates a square wave with a definite frequency. The Output alternates between HIGH and LOW state or two output voltage levels for a definite period of time. That is ON and OFF for a definite period. The oN time and OFF time can be different which determines the duty cycle of the oscillator. Duty cycle = ON time period / Total time period.
    So using an arduino a simple switching of a digital output between a HIGH and LOW state with a time delay function can be used as an astable multivibrator. Inside the void loop, it just repeats and generates a square wave of definite frequency and duty cycle.

    // HIGH for 100us and LOW for 100us. Repeats again.
    while(1){
      digitalWrite(output, HIGH);
      delayMicroseconds(100); // pauses for 100 microseconds
      digitalWrite(output, LOW);
      delayMicroseconds(100); // pauses for 100 microseconds
    }
    
    

Leave a Reply

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