External Interrupt example for WIZwiki-W7500 Academy

Dependencies:   mbed

Fork of GPIOIn_INT_HelloWorld_WIZwiki-W7500 by Lawrence Lee

main.cpp

Committer:
IOP
Date:
2015-07-24
Revision:
7:2b3f33a45f27
Parent:
6:41c9ebdce05b
Child:
8:d8c1d43afdf0

File content as of revision 7:2b3f33a45f27:

/* GPIO Input Interrupt Example Program */
 
#include "mbed.h"

InterruptIn mysw(D2);       // SW1 on easy module shield
DigitalOut myled_R(D9);     // LED_RED on easy module shield
DigitalOut myled_G(D10);    // LED_GREEN on easy module shield
DigitalOut myled_B(D11);    // LED_BLUE on easy module shield
 
void exin(){              // interrupt function
    myled_B = !myled_B;   // Blue LED Toggle with rising edge
}
 
int main() {
    
    myled_G = 0;       // turn off the Green LED on shield
    
    mysw.rise(&exin);         // attach the address of the exin function to the rising edge
    while(1) {                
        myled_R = !myled_R;   // Red LED switching
        wait(1.0);
    }
    
}