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.
main.cpp
- Committer:
- zeneto
- Date:
- 2018-07-04
- Revision:
- 3:81621bb4f009
- Parent:
- 2:82e0ae145867
- Child:
- 4:2eceeb929edd
File content as of revision 3:81621bb4f009:
#include "mbed.h"
#include "rtos.h"
//Interruptions
InterruptIn btn1(D7);
InterruptIn btn2(D6);
InterruptIn btn3(D5);
InterruptIn btn4(D4);
//Outs
DigitalOut buzzer(D2);
DigitalOut led(LED_BLUE);
//Buttons Threads
Thread threadb1, threadb2, threadb3, threadb4;
//Button function
void button_pressed() {
buzzer = !buzzer; // toggle the LED
led = !led;
}
//Buttons threads
void button1_thread() {
btn1.fall(&button_pressed); // whenever the button falls, execute button_pressed function
while(1) {}
}
void button2_thread() {
btn2.fall(&button_pressed); // whenever the button falls, execute button_pressed function
while(1) {}
}
void button3_thread() {
btn3.fall(&button_pressed); // whenever the button falls, execute button_pressed function
while(1) {}
}
void button4_thread() {
btn4.fall(&button_pressed); // whenever the button falls, execute button_pressed function
while(1) {}
}
int main(int, char**) {
led = !led;
threadb1.start(button1_thread);
threadb2.start(button2_thread);
threadb3.start(button3_thread);
threadb4.start(button4_thread);
while (1) {}
}