Hardware Reference
In-Depth Information
// make samples from sensors 1 for X and 3 for Y
upDateLEDs(0x45);
np = 2;
break;
case '3': // samples from sensors 1 & 2 for X and 3 for Y
upDateLEDs(0x47);
np = 3;
break;
case '4':
// samples from sensors 1 & 2 for X and 3 & 4 for Y
upDateLEDs(0xcf);
np = 4;
break;
case '5':
upDateLEDs(0x8a);
np = 5; // make samples from sensors 2 for X and 4 for Y
break;
case '6':
// make samples from sensor 1 for X and 3 & 4 for Y
upDateLEDs(0xCD);
np = 6;
break;
}
}
}
}
void encRead(){ // reads two bytes from each encoder
int hallReading = 0;
digitalWrite( CS_ENC, LOW); // enable encoder
for(int i = 0; i<npRead; i++){
delayMicroseconds(10);
digitalWrite( CK_ENC, LOW); // clock low
delayMicroseconds(10);
hallReading = 0;
for(int i=0;i<16;i++){ // read in all four bits
hallReading = hallReading << 1;
digitalWrite( CK_ENC, HIGH); // clock high
delayMicroseconds(10);
hallReading = hallReading | digitalRead(MISO_ENC);
digitalWrite( CK_ENC, LOW); // clock low
delayMicroseconds(10);
continued
Search WWH ::




Custom Search