for (i=0; i<8; i++) { PORTD |= _BV(2); // pull clock high Delay(2000); result |= (PIND & _BV(3))>>3; // read data bit if (i<7) result <<= 1; // and shift left Delay(2000); if (i<7) PORTD &= ~_BV(2); // pull clock low Delay(2000); }