I am working on a custom wheel to the Logitech G27, and in order to keep using it inside hardware to get the leds information of the RPM counter and still use its buttons, I am debugging the board that is between the wheel and it shaft.
The board consist simply of a HC595AG and a 74HC165, the HC595AG to drive the leds and the 74HC165 to read it buttons, my goal is to not use this board and put an Arduino in it place.
My first objective is to read the data that should go to HC595AG and process on the arduino, so I can drive other leds the way I want, but no matter what I try I can't read the data. Can someone help me on this?
Pin 1: Ground
Pin 2: Data from the 165
Pin 3: Data to the 595
Pin 4: Clock to both the 165 and 595.
Pin 5: Reset Clock to the 595
Pin 6: Parallel Load to the 165
Pin 7: VCC
To intercept data to the 595, connect to 0 (Ground), 3 (Data), 4 (Clock) and 5 (Reset). On each pulse of pin 4 (Clock), read a bit from pin 3 (Data). If you see a pulse on pin 5 (Reset) you should reset the input buffer.
void latch() {
for(int i = 0; i < 8; i++){
Serial.print(reg[i]);
}
Serial.println();
}
I know that "digitalRead" is slow and not recomended to the job, so I used "reg[j] = PIND & 0b00010000;" instead, but i am getting the value "16" and not "1", I am new in port manipulation, can someone help me with this?
Are you talking about the schematic?
LED1, LED2, R9, and Q8 are in series.
LED3, LED4, R10, and Q9 are in series.
LED3 and LED2 are not in series with each other.
But how is the correct way to read if a pin is high or low using PIND? I didn't find anywhere, I just wanna know the state of pin 4 of the arduino, but not using digitalRead since it is slow.
The decoupling capacitors are in the board as normally, both close to it vcc pin of the chip, I just didn't put in the schematic by lazy
//read the 4th bit in port D
if(PIND & 0b00010000 == 0b00010000)
{
Serial.println( "The 4th bit is HIGH");
}
else
{
Serial.println( "The 4th bit is LOW");
}