Created
November 27, 2015 09:25
-
-
Save MartijnBraam/e72cdcde501ed6d1f821 to your computer and use it in GitHub Desktop.
blink help
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
#include <avr/io.h> | |
#include <util/delay.h> | |
void init_io(void) | |
{ | |
// 1 = output, 0 = input | |
DDRB = 0b11111111; // All outputs | |
DDRC = 0b11111111; // All outputs | |
DDRD = 0b11111110; // PORTD (RX on PD0). Just for demo | |
} | |
void blink_s(void) | |
{ | |
PORTC = 0xFF; | |
PORTB = 0xFF; | |
PORTD = 0xFF; | |
_delay_ms(250); | |
PORTC = 0x00; | |
PORTB = 0x00; | |
PORTD = 0x00; | |
_delay_ms(250); | |
} | |
void blink_l(void) | |
{ | |
PORTC = 0xFF; | |
PORTB = 0xFF; | |
PORTD = 0xFF; | |
_delay_ms(500); | |
PORTC = 0x00; | |
PORTB = 0x00; | |
PORTD = 0x00; | |
_delay_ms(500); | |
} | |
int main(void) | |
{ | |
init_io(); | |
while (1) | |
{ | |
blink_s(); | |
blink_s(); | |
blink_s(); | |
blink_l(); | |
blink_l(); | |
blink_l(); | |
blink_s(); | |
blink_s(); | |
blink_s(); | |
_delay_ms(1000); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment