Skip to content

Instantly share code, notes, and snippets.

@NearLinHere
Last active August 29, 2015 14:14
Show Gist options
  • Save NearLinHere/f98c2ac6a73ca4abbf16 to your computer and use it in GitHub Desktop.
Save NearLinHere/f98c2ac6a73ca4abbf16 to your computer and use it in GitHub Desktop.
#include <avr/io.h>
PORTC |= (_BV(0) | _BV(1) | _BV(2)); // Set bits 0, 1, 2
PORTC &= ~(_BV(3) | _BV(4) | _BV(5)); // Clear bits 3, 4, 5
PORTC ^= (_BV(6) | _BV(7)); // Toggle bits 6, 7
//without using MACRO _BV() would looks like this
PORTC |= ((1 << 0) | (1 << 1) | (1 << 2)); // Set bits 0, 1, 2
PORTC &= ((1 << 3) | (1 << 4) | (1 << 5)); // Clear bits 3, 4, 5
PORTC ^= ((1 << 6) | (1 << 7)); // Toggle bits 6, 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment