Skip to main content
Code formatting.
Source Link
Edgar Bonet
  • 45.2k
  • 4
  • 42
  • 81

if you want to blink your LED by giving interrupt by push button then you can try this..

    int pushButton = 2;
    int LED = 13;
    volatile bool flag = false;
    volatile byte state = LOW;
    
      void setup()  
{
      pinMode(pushButton, INPUT_PULLUP);
      pinMode(LED,OUTPUT);
      attachInterrupt(digitalPinToInterrupt(pushButton), &setFlag, FALLING);
    }
    
    void loop() 
     {
      if (flag) 
              {
               digitalWrite(LED, state);
               delay(100);
               state = !state;
            }
   } 

void setFlag()
{
flag=true;
}
 

        flag = true;
}

if you want to blink your LED by giving interrupt by push button then you can try this..

    int pushButton = 2;
    int LED = 13;
    volatile bool flag = false;
    volatile byte state = LOW;
    
      void setup() {
      pinMode(pushButton, INPUT_PULLUP);
      pinMode(LED,OUTPUT);
      attachInterrupt(digitalPinToInterrupt(pushButton), &setFlag, FALLING);
    }
    
    void loop() 
     {
      if (flag) 
              {
               digitalWrite(LED, state);
               delay(100);
               state = !state;
            }
   }
void setFlag()
{
flag=true;
}
 

          

if you want to blink your LED by giving interrupt by push button then you can try this..

int pushButton = 2;
int LED = 13;
volatile bool flag = false;
volatile byte state = LOW;

void setup() 
{
    pinMode(pushButton, INPUT_PULLUP);
    pinMode(LED,OUTPUT);
    attachInterrupt(digitalPinToInterrupt(pushButton), &setFlag, FALLING);
}

void loop() 
{
    if (flag) 
    {
        digitalWrite(LED, state);
        delay(100);
        state = !state;
    }
} 

void setFlag()
{
    flag = true;
}
added 32 characters in body
Source Link
Prayuktibid
  • 362
  • 1
  • 5
  • 18

if you want to blink your LED by giving interrupt by push button then you can try this..

    int pushButton = 2;
    int LED = 13;
    volatile bool flag = false;
    volatile byte state = LOW;
    
      void setup() {
      pinMode(pushButton, INPUT_PULLUP);
      pinMode(LED,OUTPUT);
      attachInterrupt(digitalPinToInterrupt(pushButton), &setFlag, FALLING);
    }
    
    void loop() 
     {
      if (flag) 
              {
               digitalWrite(LED, state);
               delay(100);
               state = !state;
            }
   }
void setFlag()
{
flag=true;
}
 

          

if you want to blink your LED by giving interrupt by push button then you can try this..

    int pushButton = 2;
    int LED = 13;
    volatile bool flag = false;
    volatile byte state = LOW;
    
      void setup() {
      pinMode(pushButton, INPUT_PULLUP);
      pinMode(LED,OUTPUT);
      attachInterrupt(digitalPinToInterrupt(pushButton), &setFlag, FALLING);
    }
    
    void loop() 
     {
      if (flag) 
              {
               digitalWrite(LED, state);
               state = !state;
            }
   }
void setFlag()
{
flag=true;
}
 

          

if you want to blink your LED by giving interrupt by push button then you can try this..

    int pushButton = 2;
    int LED = 13;
    volatile bool flag = false;
    volatile byte state = LOW;
    
      void setup() {
      pinMode(pushButton, INPUT_PULLUP);
      pinMode(LED,OUTPUT);
      attachInterrupt(digitalPinToInterrupt(pushButton), &setFlag, FALLING);
    }
    
    void loop() 
     {
      if (flag) 
              {
               digitalWrite(LED, state);
               delay(100);
               state = !state;
            }
   }
void setFlag()
{
flag=true;
}
 

          
added 134 characters in body
Source Link
Prayuktibid
  • 362
  • 1
  • 5
  • 18

if you want to blink your LED by giving interrupt by push button then you can try this..

    int pushButton = 2;
    int LED = 13;
    volatile bool flag = false;
    volatile byte state = LOW;
    
      void setup() {
      pinMode(pushButton, INPUT_PULLUP);
      pinMode(LED,OUTPUT);
      attachInterrupt(digitalPinToInterrupt(pushButton), &setFlag, FALLING);
    }
    
    void loop() 
     {
      if (flag) 
              {
               digitalWrite(LED, state);
               state = !state;
            }
   }
void setFlag()
{
flag=true;
}
 

          

}

if you want to blink your LED by giving interrupt by push button then you can try this..

int pushButton = 2;
int LED = 13;
volatile bool flag = false;
volatile byte state = LOW;

  void setup() {
  pinMode(pushButton, INPUT_PULLUP);
  pinMode(LED,OUTPUT);
  attachInterrupt(digitalPinToInterrupt(pushButton), &setFlag, FALLING);
}

void loop() 
 {
  if (flag) 
          {
           digitalWrite(LED, state);
           state = !state;
        }

}

if you want to blink your LED by giving interrupt by push button then you can try this..

    int pushButton = 2;
    int LED = 13;
    volatile bool flag = false;
    volatile byte state = LOW;
    
      void setup() {
      pinMode(pushButton, INPUT_PULLUP);
      pinMode(LED,OUTPUT);
      attachInterrupt(digitalPinToInterrupt(pushButton), &setFlag, FALLING);
    }
    
    void loop() 
     {
      if (flag) 
              {
               digitalWrite(LED, state);
               state = !state;
            }
   }
void setFlag()
{
flag=true;
}
 

          
Source Link
Prayuktibid
  • 362
  • 1
  • 5
  • 18
Loading