Tina Dokic
/
Uebungen_T_D
LEDs blinken von LED1-LED4,und fangen an von momentane Position an. l
Revision 0:72b3da7b1d49, committed 2020-01-12
- Comitter:
- tina_dokic
- Date:
- Sun Jan 12 19:59:58 2020 +0000
- Commit message:
- BitManipulation
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 Sun Jan 12 19:59:58 2020 +0000 @@ -0,0 +1,57 @@ +#include "mbed.h" + +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); + +uint8_t pos = 0; +uint8_t shift = 0; // change the value between 0 and 3 + +int main() { + while (1) { + pos = (1 << shift); // shift left + if(pos == 0b00001000) + { led4 = 1; + wait_ms(100); + led4=0; + led1=1; + wait(0.1); + led1=0; + led2 = 1; + wait_ms(100); + led2=0; + led3 = 1; + wait_ms(100); + led3=0; + } + if(pos == 0b00000100) + { led3 = 1; + wait_ms(100); + led3=0; + led4=1; + wait(0.1); + led4=0; + led1 = 1; + wait_ms(100); + led1=0; + led2= 1; + wait_ms(100); + led2=0; + } + if(pos == 0b00000001) + { led1 = 1; + wait_ms(400); + led1=0; + led2=1; + wait(0.4); + led2=0; + led3 = 1; + wait_ms(400); + led3=0; + led4 = 1; + wait_ms(400); + led4=0; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Jan 12 19:59:58 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file