#include #include #define RCK 0 //STCP #define SCK 1 //SHCP #define DS 2 #define OE 3 #define MR 4 #define setbit(p,n) p|=_BV(n) #define clearbit(p,n) p&=~_BV(n) #define time 100 void writebyte(char b); int main(void) {char i; DDRA=0; PORTA=0x00; DDRB=0xff; DDRD=0xff; UCSRA=0x00; PORTD=0x00; setbit(PORTD,MR); clearbit(PORTD,OE); for (i=240;1;i++){ writebyte(i); PORTB=PINA; _delay_ms(200); PORTB=PINA; _delay_ms(800); } while (1) asm("nop"); } void writebyte(char b) { for (char i=0;i<=7;i++){ if (_BV(i)&b) {setbit(PORTD,DS);} else {clearbit(PORTD,DS);} _delay_us(12); setbit(PORTD,SCK); clearbit(PORTD,SCK); } setbit(PORTD,RCK); clearbit(PORTD,RCK); }