Question: Arduino coding help : - Here, i have a code for interrupt when a button is pressed, led turns on and goes off Code :

Arduino coding help :

- Here, i have a code for interrupt when a button is pressed, led turns on and goes off

Code : ATMega329p with uno breadboard

#include //provide set of default interrupt routines

//pointer direct to specific address

unsigned char* pEICRA = reinterpret_cast (0x69); unsigned char* pEIMSK = reinterpret_cast (0x3D); void setup(void) { pinMode(2, INPUT); // Push Button as 2 pinMode(13, OUTPUT); // LED as 13 *pEICRA = 0x03; //re *pEIMSK |= (1 << INT0); sei(); // Sets the bit and switches interrupts on } void loop(void) //need if function to tell true { Help !!!! }

ISR(INT0_vect) { digitalWrite(13, HIGH); delay(3000); digitalWrite(13, LOW); cli(); // Clears the global interrupt flag }

1 ) I need help in the loop function. ' if ' statement for true when push button is pushed, LED should stay for 3 sec.

Thank you.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!