Home / Expert Answers / Computer Science / modify-the-previous-code-so-when-push-button-2-is-pressed-led3-blinks-10-times-at-a-rate-of-2-hz-or-pa373

(Solved): Modify the previous code so when Push Button 2 is pressed LED3 blinks 10 times at a rate of 2 Hz or ...



Blink_ISR.c x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
HE
#include<wiringPi.h>
int LED = 1;
int LED2 = 4;
int PushB = 6;
void ISR_fun

Modify the previous code so when Push Button 2 is pressed LED3 blinks 10 times at a rate of 2 Hz or twice per second.  Since you are using pull-down resistor for the second push-button, interrupt at the rising edge must be used for it.

Blink_ISR.c x 1 2 3 4 5 6 7 8 9 10 11 12 13 14 HE #include int LED = 1; int LED2 = 4; int PushB = 6; void ISR_function() //Interrupt Sevice routine to blink LED 5 times 8{ H= 8 for (int i=0; i<5; i++) { 8 } 15 int main() 16 9{ 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 digitalWrite(LED, HIGH); delay(1000); digitalWrite(LED, LOW); delay(1000); wiringPiSetup(); pinMode(LED, OUTPUT); pinMode(LED2, OUTPUT); //Detect interrupt on the fallng edge on physical pin22 and call ISR wiringPiISR(PushB, INT_EDGE_FALLING, &ISR_function); while (1) { digitalWrite(LED2, HIGH); delay(500); digitalWrite(LED2, LOW); delay(500); return 0;


We have an Answer from Expert

View Expert Answer

Expert Answer


pl
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe