Hi everybody. I am making a 64 led pov globe because i think they are one of the coolest things ever. I am using a Atmega328p as the brains, and 8 8-bit shift registers to run the leds. Now I am not a very big programmer so my code is very basic. I was wondering if there was a more efficient way than I have to write the code, to flash the leds. My code is

Code: Select all

As you can tell it is very long and takes up some memory. And it is just a piece of test code to see if all the leds work.```
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
int cycle(int data);
int latch(void);
int main(void)
{
DDRB = 0b000111;
PORTB = 0b000000;
while(1)
{
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
latch();
_delay_ms(2.5);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
cycle(1);
cycle(0);
latch();
_delay_ms(2.5);
}
return 1;
}
int latch(void)
{
PORTB |= (1 << PIN2);
PORTB &= ~(1 << PIN2);
return 1;
}
int cycle(int data)
{
if (data == 0)
{
PORTB &= ~(1 << PIN0);
PORTB |= (1 << PIN1);
PORTB &= ~(1 << PIN1);
}
else
{
PORTB |= (1 << PIN0);
PORTB |= (1 << PIN1);
PORTB &= ~(1 << PIN1);
}
return 1;
}
```