Skip to content

Instantly share code, notes, and snippets.

@pilinux
Created February 18, 2016 20:13
Show Gist options
  • Save pilinux/01208571e812aca01578 to your computer and use it in GitHub Desktop.
Save pilinux/01208571e812aca01578 to your computer and use it in GitHub Desktop.
bit shifting
// ------- Preamble ------- //
#include <avr/io.h>
#include <util/delay.h> /* Time delay function */
int main(void) {
// ------- Inits ------- //
DDRB = 0b11111111; /* Port-B configured for output */
uint8_t i; /* unsigned 8-bit integer */
// ------- Event loop ------- //
while(1){
for (i=0; i<6; i++){
PORTB = 0b00000001 << i;
_delay_ms(500);
}
}
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