Bernd Eisenberger
/
Tinf_002_Bitmanipulation
Lauflicht mit Button
Revision 1:51299916db3e, committed 2019-12-02
- Comitter:
- Berndii__
- Date:
- Mon Dec 02 18:26:11 2019 +0000
- Parent:
- 0:1b90d953ef92
- Commit message:
- Lauflicht mit Button
Changed in this revision
Tinf_001_DigitalIn.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 1b90d953ef92 -r 51299916db3e Tinf_001_DigitalIn.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tinf_001_DigitalIn.lib Mon Dec 02 18:26:11 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/fpucher/code/DigitalIn/#1b90d953ef92
diff -r 1b90d953ef92 -r 51299916db3e main.cpp --- a/main.cpp Wed Nov 13 13:52:25 2019 +0000 +++ b/main.cpp Mon Dec 02 18:26:11 2019 +0000 @@ -1,15 +1,72 @@ -#define BUTTON1 p14 #include "mbed.h" -// Flash an LED while a DigitalIn is true + +#define Button1 p12 +#define Button3 p14 +#define Button2 p15 + + + +BusOut myleds(LED4, LED3, LED2, LED1); + +DigitalIn up(Button1); +DigitalIn down(Button2); +DigitalIn center(Button3); + +int main() +{ + while(1) { + + + + if(up.read()==1) { + if(myleds<=14) { + wait_ms(50); + myleds=myleds<<1; + myleds=1|myleds; + + } + + if(myleds>=14) { + + wait_ms(50); + myleds=myleds<<1; + myleds=myleds|0; -DigitalIn enable(BUTTON1); -DigitalOut led(LED1); - -int main() { - while(1) { - if(enable) { - led = !led; + } + + + + + + } + if(center.read()==1) { + wait_ms(100); + for(int i=0; i<4; i++) { + wait_ms(100); + myleds=myleds<<1; + myleds=myleds|0; + } } - wait(0.25); + + + if(down.read()==1) { + if(myleds<=15) { + wait_ms(50); + myleds=myleds>>1; + myleds=0|myleds; + + } + + if(myleds>=15) { + + wait_ms(50); + myleds=myleds>>1; + myleds=myleds|0; + + } + + + } +} } \ No newline at end of file