Page 1 of 1

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 IS

Posted: Sun Jul 03, 2022 11:59 am
by answerhappygod
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 Is 1
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 Is 1 (75.49 KiB) Viewed 22 times
Modify the previous code so when Push Button 2 ispressed LED3 blinks 10 times at a rate of 2 Hz or twice persecond. Since you are using pull-down resistor for the secondpush-button, interrupt at the rising edge must be used forit.
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_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;