Polling

Dependencies:   mbed

main.cpp

Committer:
sandeshkumar
Date:
2015-02-02
Revision:
0:ecb474821d8f

File content as of revision 0:ecb474821d8f:

#include "mbed.h"
 
InterruptIn pin22(p22);
InterruptIn pin23(p23);
DigitalOut led1(LED1);
DigitalOut led2(LED2);

DigitalOut pin17(p17);
DigitalOut pin18(p18);
DigitalOut pin19(p19);
DigitalOut pin20(p20);
 
void riseLed1() {
    led1 = 1;
}

void fallLed1() {
    led1 = 0;
}

void riseLed2() {
    led2 = 1;
}

void fallLed2() {
    led2 = 0;
}
 
int main() {
    pin17 = 1;
    pin18 = 1;
    pin19 = 1;
    pin20 = 1;
    
    pin22.rise(&riseLed1);  // attach the address of the flip function to the rising edge
    pin23.rise(&riseLed2);  // attach the address of the flip function to the rising edge
    pin22.fall(&fallLed1);
    pin23.fall(&fallLed2);
    while(1) {           // wait around, interrupts will interrupt this!
        wait(0.1);
    }
    
    
}

/*#include "mbed.h"
#include "keypad.h"
 
 // Define your own keypad values
 char Keytable[] = { '1', '2', '3', 'A',
                     '4', '5', '6', 'B',
                     '7', '8', '9', 'C',
                     '*', '0', '#', 'D'
                   };
 
 uint32_t cbAfterInput(uint32_t index) {
     printf("Index:%d => Key:%c\n", key, Keytable[index]);
     return 0;
 }
 
 int main() {
     Keypad keypad(p25, p26, p27, p28, p21, p22, p23, p24);
     keypad.CallAfterInput(&cbAfterInput);
     keypad.Start();
 
     while (1) {
         wait_ms(100);
     }
 }*/