3. Aufgaben _ Bitmanipulationen Grundlegend

Dependencies:   mbed

main.cpp

Committer:
riad
Date:
2020-01-11
Revision:
2:84519c8101cb
Parent:
1:af76e894b90f

File content as of revision 2:84519c8101cb:

#include "mbed.h"
 
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);

uint8_t pos = 0;
uint8_t shift = 3;    

int main() {
    while (1) {
        pos = (1 << shift); // shift left
        printf("%x\n", pos);
        if(pos == 0x08)
            led4 = !led4;
        if(pos == 0x04)
            led3 = !led3;
        if(pos == 0x02)
            led2 = !led2;
        if(pos == 0x01)
            led1 = !led1;
        wait_ms(500);
    }
}