Stefan Hutter
/
Hutter_13_10_2020
Lustiges Blinkspiel
Revision 0:97e60ecbed65, committed 2020-10-13
- Comitter:
- Hutzi
- Date:
- Tue Oct 13 16:46:29 2020 +0000
- Commit message:
- Lustiges Blinkspiel
Changed in this revision
main.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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 13 16:46:29 2020 +0000 @@ -0,0 +1,82 @@ +#include "mbed.h" + + +class MyClass{ + + + + public: + MyClass() : _delay(250), _Led(LED1) { + + } + MyClass(int delay, PinName Pin) : _delay(delay), _Led(Pin) { + + } + + + void blink(){ + //DigitalOut led(_Pin); + + _Led=1; + printf("Blink! LED with delay %d is %d \n", _delay, _Led.read()); + + wait_ms(_delay); + + _Led=0; + printf("Blink! LED with delay %d is %d \n", _delay, _Led.read()); + + wait_ms(_delay); + } + + + int blink(int blinkzahl){ + + if(blinkzahl>0){ + + + for(int i=0; i<blinkzahl; i++){ + + _Led=1; + wait_ms(70); + _Led=0; + wait_ms(70); + } + + //printf("Led hat %d mal geblinkt \n", blinkzahl); + return blinkzahl; + } + + return 0; + } + + + private: + const int _delay; + DigitalOut _Led; + +}; + + +MyClass blinkDefault; +MyClass blink(1000,LED2); + + + +int main() { + + int blinkzahl = blink.blink(10); + printf("Led hat %d mal geblinkt \n", blinkzahl); + + + + while (1) { + + + blinkDefault.blink(); // Delays kommen sich in die quere + // blink.blink(); + + + } +} + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Oct 13 16:46:29 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file