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

copy leds.c+makefile to speedyleds

parent ba652216
No related branches found
No related tags found
No related merge requests found
speedyleds.hex: speedyleds.o
avr-objcopy -j .text -j .data -O ihex speedyleds.o speedyleds.hex
speedyleds.o:
avr-gcc speedyleds.c -o speedyleds.o -Wall -Wextra -Wpedantic -mmcu=atmega328p -Os -std=c99
flash:
avrdude -p atmega328p -c gpio -U flash:w:speedyleds.hex
#define F_CPU 12000000UL
#include<util/delay.h>
#include<avr/io.h>
#include<avr/libc.h>
int main(void){
DDRD = 0b11111100;
DDRB = 0b00111111;
PORTD = 0b00000011;
PORTB = 0b00000000;
char on = 0;
while(1){
while(!on){
if(PORTD != 0b11111111) PORTD = (PORTD<<1)+1;
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);
}
}
}
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