Da wird gezeigt bei einem überladenen Operator, wie elegant man den Status eines Tasters einlesen und auf eine Led ausgeben kann.
Revision 0:c6567f86bdfe, committed 2020-01-15
- Comitter:
- besam
- Date:
- Wed Jan 15 00:40:49 2020 +0000
- Commit message:
- Letzte Version
Changed in this revision
Mbed_Dig_IN1.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r c6567f86bdfe Mbed_Dig_IN1.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Mbed_Dig_IN1.cpp Wed Jan 15 00:40:49 2020 +0000 @@ -0,0 +1,14 @@ +//#define BUTTON1 p14 // push joystick pin +//#define BUTTON1 A1 // Taster A1 ----wenn online Simulator verwendet wird + +#include "mbed.h" + +DigitalOut led(LED1); +DigitalIn button(BUTTON1); + +int main() { + while (1) { + led = button; // Equivalent to led.write(button.read()) + wait_ms(50); + } +}
diff -r 000000000000 -r c6567f86bdfe mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jan 15 00:40:49 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file