Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup() {
- DDRC |= _BV(0) | _BV(1) | _BV(3);
- PORTC=0x00;
- }
- void loop()
- {
- long a;
- for(a = 0; a < 128; a+= 1)
- {
- PORTC &= ~( _BV(3));
- shiftOut(a);
- PORTC |= ( _BV(3));
- }
- for(a = 128; a > 0 ; a-= 1)
- {
- PORTC &= ~( _BV(3));
- shiftOut(a);
- PORTC |= ( _BV(3));
- }
- }
- void shiftOut(long myDataOut)
- {
- int pinState;
- PORTC &= ~( _BV(0));
- PORTC &= ~( _BV(1));
- int outPut;
- for (outPut=0; outPut < 24; outPut++) //24 different outputs
- {
- for(int val = 11; val >= 0; val--) //12 bit number
- {
- PORTC &= ~( _BV(1));
- if ( myDataOut & (1<<val) )
- {
- pinState = 1;
- PORTC |= ( _BV(0));
- }
- else
- {
- pinState= 0;
- PORTC &= ~( _BV(0));
- }
- PORTC |= ( _BV(1));
- PORTC &= ~( _BV(0));
- }
- }
- PORTC &= ~( _BV(1));
- }
Advertisement
Add Comment
Please, Sign In to add comment