Skip to content

Instantly share code, notes, and snippets.

@pilinux
Created February 12, 2016 10:21
Show Gist options
  • Save pilinux/d2a37fee3e418f196cc6 to your computer and use it in GitHub Desktop.
Save pilinux/d2a37fee3e418f196cc6 to your computer and use it in GitHub Desktop.
Set bit with OR operation
// ------- Preamble ------- //
#include <avr/io.h>
#include <util/delay.h> /* Time delay function */
#define DELAYTIME 250 /* milliseconds */
#define LED_PORT PORTB
#define LED_DDR DDRB
int main(void) {
uint8_t i;
// ------- Inits ------- //
LED_DDR = 0xff; /* all LEDs are configured for output */
// ------- Event loop ------- //
while(1) {
for (i=0; i<6; i++) {
LED_PORT |= _BV(i); // LED_PORT |= (1 << i);
_delay_ms(DELAYTIME);
}
LED_PORT = 0;
_delay_ms(DELAYTIME * 2);
}
return(0); /* this line is never reached */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment