Riad_ Bajraktarevic
/
BinHexDezVergl
3. Aufgaben _ Bitmanipulationen Grundlegend
BinHexDezVergl.cpp@5:d504dff6ddb6, 2020-01-11 (annotated)
- Committer:
- riad
- Date:
- Sat Jan 11 12:11:38 2020 +0000
- Revision:
- 5:d504dff6ddb6
- Parent:
- 4:9800111f62df
[BinHexDezVergl]
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
riad | 0:1c659c1a1cb9 | 1 | #include "mbed.h" |
riad | 0:1c659c1a1cb9 | 2 | |
riad | 0:1c659c1a1cb9 | 3 | DigitalOut led1(LED1); |
riad | 0:1c659c1a1cb9 | 4 | DigitalOut led2(LED2); |
riad | 0:1c659c1a1cb9 | 5 | DigitalOut led3(LED3); |
riad | 0:1c659c1a1cb9 | 6 | DigitalOut led4(LED4); |
riad | 1:af76e894b90f | 7 | |
riad | 1:af76e894b90f | 8 | uint8_t pos = 0; |
riad | 4:9800111f62df | 9 | uint8_t shift = 4; |
riad | 1:af76e894b90f | 10 | |
riad | 2:84519c8101cb | 11 | int main() { |
riad | 2:84519c8101cb | 12 | while (1) { |
riad | 2:84519c8101cb | 13 | pos = (1 << shift); // shift left |
riad | 2:84519c8101cb | 14 | printf("%x\n", pos); |
riad | 2:84519c8101cb | 15 | if(pos == 0x08) |
riad | 2:84519c8101cb | 16 | led4 = !led4; |
riad | 2:84519c8101cb | 17 | if(pos == 0x04) |
riad | 2:84519c8101cb | 18 | led3 = !led3; |
riad | 2:84519c8101cb | 19 | if(pos == 0x02) |
riad | 2:84519c8101cb | 20 | led2 = !led2; |
riad | 2:84519c8101cb | 21 | if(pos == 0x01) |
riad | 2:84519c8101cb | 22 | led1 = !led1; |
riad | 4:9800111f62df | 23 | if(pos == 0x10) |
riad | 4:9800111f62df | 24 | led1 = !led1; |
riad | 4:9800111f62df | 25 | led2 = !led2; |
riad | 4:9800111f62df | 26 | led3 = !led3; |
riad | 4:9800111f62df | 27 | led4 = !led4; |
riad | 5:d504dff6ddb6 | 28 | |
riad | 2:84519c8101cb | 29 | wait_ms(500); |
riad | 2:84519c8101cb | 30 | } |
riad | 2:84519c8101cb | 31 | } |