Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MASKIREN
- include "mbed.h"
BusOut myleds(LED1, LED2, LED3, LED4);
void print_binary(uint8_t x) { function to print binary
for(int i=sizeof(x)<<3; i; i)
putchar('0'+((x>>(i-1))&1));
}
int main() { uint8_t value = 0b01010110; C++14 Standard Extension uint8_t mask = 0b00001111; mask lower nibble uint8_t position = 0; for later use is position of bit in mask
scanf("%d", &value); printf("value : "); print_binary(value); call function print_binary printf("\nmask : "); print_binary(mask); value = mask & value; myleds = value; printf("\nresult: "); print_binary(myleds.read());
printf("\n\nshift left: %X\n", value<<1); printf("shift right: %X\n", value>>1); }