sysprog-basic/blink/main.c

33 lines
578 B
C
Raw Normal View History

2023-10-26 12:08:52 +02:00
#define F_CPU 16000000UL
2023-10-27 10:52:58 +02:00
#define __AVR_ATmega328P__
2023-10-26 11:56:25 +02:00
#include <avr/io.h>
#include <util/delay.h>
2023-10-27 10:52:58 +02:00
int main(void) {
DDRB = 0xff;
2023-10-26 12:08:52 +02:00
2023-10-27 10:52:58 +02:00
while (1) {
// green
PORTB |= (1 << PORTB5);
_delay_ms(500);
PORTB &= ~(1 << PORTB5);
2023-10-26 12:08:52 +02:00
2023-10-27 10:52:58 +02:00
// yellow
PORTB |= (1 << PORTB4);
_delay_ms(500);
PORTB &= ~(1 << PORTB4);
2023-10-26 12:08:52 +02:00
2023-10-27 10:52:58 +02:00
// red
PORTB |= (1 << PORTB3);
_delay_ms(500);
PORTB &= ~(1 << PORTB3);
2023-10-26 12:08:52 +02:00
2023-10-27 10:52:58 +02:00
// red and yellow
PORTB |= (1 << PORTB3);
PORTB |= (1 << PORTB4);
_delay_ms(500);
PORTB &= ~(1 << PORTB3);
PORTB &= ~(1 << PORTB4);
}
2023-10-26 11:56:25 +02:00
}