Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- void shift(char data);
- char cnt = 0;
- int main()
- {
- DDRB = 0xFF;
- PORTB = 0xFF;
- TCCR0B |= (1 << CS00) | (1 << CS02);
- for(;;)
- {
- if (TCNT0 > 200)
- {
- cnt++;
- shift(cnt);
- TCNT0 = 0;
- }
- if (cnt > 254)
- {
- cnt = 0;
- }
- }
- return 0;
- }
- void shift(char data)
- {
- PORTB &= ~(1 << PB2);
- for (int i = 0; i < (8); i++)
- {
- PORTB &= ~(1 << PB1);
- PORTB |= (((data&(0x01<<i))>>i) << PB0 );
- PORTB |= (1 << PB1);
- PORTB &= ~(((data&(0x01<<i))>>i) << PB0 );
- }
- PORTB |= (1 << PB2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement