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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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 21 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;
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply