Skip to content
Snippets Groups Projects
Commit 2e381def authored by Julia Scharsich's avatar Julia Scharsich
Browse files

leds.c - not perfect but does work

parent 6da3dd8c
No related branches found
No related tags found
No related merge requests found
leds.hex: leds.o
avr-objcopy -j .text -j .data -O ihex leds.o leds.hex
leds.o:
avr-gcc leds.c -o leds.o -Wall -Wextra -Wpedantic -mmcu=atmega328p -Os -std=c99
flash:
avrdude -p atmega328p -c gpio -U flash:w:leds.hex
...@@ -4,13 +4,27 @@ ...@@ -4,13 +4,27 @@
#include<avr/io.h> #include<avr/io.h>
int main(void){ int main(void){
DDRD = 0b00111111; DDRD = 0b11111100;
DDRB = 0b11111100; DDRB = 0b00111111;
PORTD = 0b00000000; PORTD = 0b00000011;
PORTB = 0b00000000; PORTB = 0b00000000;
char on = 0;
while(1){ while(1){
if(PORTD != 0b11111111) PORTD = PORTD<<1+1; while(!on){
if(PORTB != 0b11111111) PORTB = PORTB<<1+1; if(PORTD != 0b11111111) PORTD = (PORTD<<1)+1;
_delay_ms(1000); else{
if(PORTB != 0b11111111) PORTB = (PORTB<<1)+1;
else on=1;
}
_delay_ms(250);
}
while(on){
if(PORTB != 0b00000000) PORTB = (PORTB-1)>>1;
else{
if(PORTD != 0b00000011) PORTD = (PORTD-1)>>1;
else on=0;
}
_delay_ms(250);
}
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment