m168-programming/blink/blinkled.c

35 lines
734 B
C

#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
/*
the DDRX registers are used to indicated whether each pin
is being used for input or output (data direction)
to enable a pin as output you set its corresponding bit to 1,
the default state is 0 (input)
*/
DDRB |= 0b00000001;
while (1) {
/*
When DDRx is set to 1 (output):
PORTx controls whether that port register is set to high or low.
When DDRx is set to 0 (input) it is essentially disconnected
from the circuit
*/
PORTB = 0b00000001; // turn on the LED
_delay_ms(50);
PORTB = 0b00000000;
_delay_ms(1000);
}
return(0);
}