-
-
Save pilinux/d2a37fee3e418f196cc6 to your computer and use it in GitHub Desktop.
Set bit with OR operation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------- 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