interrupt_receiver

Dependencies:   SLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_digital_pin_interruption_receiver.cpp Source File

mbed_digital_pin_interruption_receiver.cpp

00001 #include "mbed.h"
00002 #include "SLCD.h"
00003 
00004 /*
00005 SLCD slcd;
00006 
00007 int main() {
00008     
00009     DigitalIn gpo(D1);
00010     DigitalOut led(LED_RED);
00011     DigitalOut led1(LED1);
00012     
00013     slcd.printf("7777");
00014     
00015     led1 = 0;
00016     
00017     while (true) {
00018         if (gpo == 1)
00019             led1 = 1; 
00020         else
00021             led1 = 0;
00022     }
00023 }
00024 */
00025 //----------------------------------------------
00026 
00027 SLCD slcd;
00028 DigitalOut led(LED_RED);
00029 DigitalOut led1(LED1);
00030 DigitalOut gpoD1(D1);
00031 InterruptIn gpoD2(D2);
00032 
00033 int count = 0;
00034 
00035 void flip() {
00036     led = !led;
00037     count++;
00038     slcd.printf("%4d", count);
00039 }
00040 
00041 int main() {
00042     slcd.printf("8888");
00043     
00044     gpoD2.rise(&flip);
00045     while (true) {
00046         led = !led;
00047         gpoD1 = !gpoD1;
00048         //slcd.printf("");
00049         wait(0.5);
00050     }
00051 }