Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of InterruptIn_HelloWorld by
main.cpp
00001 #include "mbed.h" 00002 00003 InterruptIn button(USER_BUTTON); 00004 Serial pc(SERIAL_TX, SERIAL_RX); 00005 DigitalOut led(LED1); 00006 int buttonPushCounter = 0; // counter for the number of button presses 00007 00008 void buttonPressed() 00009 { 00010 buttonPushCounter++; 00011 00012 if (buttonPushCounter % 4 == 0) led = 1; 00013 else led = 0; 00014 00015 pc.printf("number of button pushes: %d.\n", buttonPushCounter); 00016 } 00017 00018 void buttonReleased() 00019 { 00020 00021 } 00022 00023 void setup() 00024 { 00025 button.mode(PullUp); 00026 pc.baud(9600); 00027 button.rise(&buttonReleased); // attach the address of the buttonReleased function to the rising edge 00028 button.fall(&buttonPressed); // attach the address of the buttonPressed function to the falling edge 00029 } 00030 00031 void loop() 00032 { 00033 // put your main code here, to run repeatedly: 00034 00035 } 00036 00037 int main() 00038 { 00039 setup(); 00040 while(1) loop(); 00041 }
Generated on Fri Jul 15 2022 19:16:36 by
1.7.2
