MENGLU WU / Mbed 2 deprecated Lab1_Part2_own

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers interrupt.cpp Source File

interrupt.cpp

00001 #include "mbed.h"
00002 
00003 InterruptIn     P5(p5); //connected to 1kohms resistor and PIN5 of the keypad
00004 InterruptIn     P6(p6); //connected to 1kohms resistor and PIN6 of the keypad
00005 DigitalOut     P7(p7);//connected to PIN8 of the keypad
00006 DigitalOut     P8(p8);//connected to PIN4 of the keypad
00007 DigitalOut    Led1(LED1);
00008 DigitalOut    Led2(LED2);
00009 
00010 void flip1(){
00011     Led1 = 1; 
00012     //Led1 = !Led1;
00013     }
00014     
00015 void flip2(){
00016      Led2 = 1;
00017     //Led2 = !Led2;
00018     }
00019     
00020 void clear() {
00021     Led1 = 0;
00022     Led2 = 0;
00023     }
00024     
00025 int main()
00026 {
00027     //set on both PIN8 and PIN4 of the keypad to detect which button is pressed.
00028     P7 = 1;
00029     P8 = 1;
00030     P5.rise(&flip1);
00031     P5.fall(&clear);
00032         P6.rise(&flip2);
00033         P6.fall(&clear);
00034 //    P5.rise(&flip1);
00035 //    P5.fall(&flip1);
00036 //        P6.rise(&flip2);
00037 //        P6.fall(&flip2);
00038     while(1) {
00039         
00040         }
00041 }
00042 
00043  
00044