unbreakmat
Member
hello there
i want to attach a 74hc165 to a teensy 4.1
i found a tutorial for arduino and there it works, so i tried hooking it up to my teensy 4.1 buth bthere everything goes wrong, i read so much different theads that i completely f*****cked it up
https://www.woolseyworkshop.com/2021/02/18/adding-digital-io-to-your-arduino-part-2-the-74hc165/
this is the scheme i use:
https://i0.wp.com/www.woolseyworksh...o_74HC165_Schematic.png?resize=1140,459&ssl=1
this is my code
first of al i think my wiring the three cables to teensy is wrong?
i dont see it anymore and becoming confused of the different posts on internet
could someone help me to wire it correctly?
and second of al could someone help me to justify the code so that is working correctly
i think i have made some clock mistakes
also i read in some topics thats the teebsy 4.1 would be to fast, tried lowering to 24mhz but stil no results
any help would be gratefully appreciated!
im really lost on this one and need someone who has done this already and could help me
please pm me if you need more information
oh yeh one thing i use a 5volt external adaptor and made the correct adjustments to the teensy for not frying it ;-)
i want to attach a 74hc165 to a teensy 4.1
i found a tutorial for arduino and there it works, so i tried hooking it up to my teensy 4.1 buth bthere everything goes wrong, i read so much different theads that i completely f*****cked it up
https://www.woolseyworkshop.com/2021/02/18/adding-digital-io-to-your-arduino-part-2-the-74hc165/
this is the scheme i use:
https://i0.wp.com/www.woolseyworksh...o_74HC165_Schematic.png?resize=1140,459&ssl=1
this is my code
Code:
const unsigned long SamplePeriod = 5000; // sampling period in milliseconds
const uint8_t ISRDataPin = 14; // connected to 74HC165 QH (9) pin //datapin
const uint8_t ISRLatchPin = 11; // connected to 74HC165 SH/LD (1) pinMISO0
const uint8_t ISRClockPin = 10; // connected to 74HC165 CLK (2) pin //clock pin t 35 CS0 10 op41
void setup() {
Serial.begin(9600);
while (!Serial);
// 74HC165 shift register
pinMode(ISRDataPin, INPUT);
pinMode(ISRLatchPin, OUTPUT);
pinMode(ISRClockPin, OUTPUT);
}
void loop() {
static unsigned long previousTime = 0;
unsigned long currentTime = millis();
if (currentTime - previousTime >= SamplePeriod) {
//readInputsWithDigitalRead();
//readInputsWithBinaryValues();
update();
// readShiftRegisters();
previousTime = currentTime;
}
}
uint8_t isrReadRegister() {
uint8_t inputs = 0;
digitalWrite(ISRClockPin, HIGH); // preset clock to retrieve first bit
digitalWrite(ISRLatchPin, HIGH); // disable input latching and enable shifting
inputs = shiftIn(ISRDataPin, ISRClockPin, MSBFIRST); // capture input values
digitalWrite(ISRLatchPin, LOW); // disable shifting and enable input latching
return inputs;
}
void update() {
static uint8_t previousInputs = 0;
uint8_t currentInputs = isrReadRegister(); // read all inputs from shift register
if (currentInputs != previousInputs) { // print values only if they changed
Serial.print("Inputs: 0b"); // print all inputs represented as a full byte
for (int8_t i = 7; i >= 0; i--) {
Serial.print(bitRead(currentInputs, i)); // print value for each bit
}
Serial.println();
previousInputs = currentInputs;
}
}
first of al i think my wiring the three cables to teensy is wrong?
i dont see it anymore and becoming confused of the different posts on internet
could someone help me to wire it correctly?
and second of al could someone help me to justify the code so that is working correctly
i think i have made some clock mistakes
also i read in some topics thats the teebsy 4.1 would be to fast, tried lowering to 24mhz but stil no results
any help would be gratefully appreciated!
im really lost on this one and need someone who has done this already and could help me
please pm me if you need more information
oh yeh one thing i use a 5volt external adaptor and made the correct adjustments to the teensy for not frying it ;-)
Last edited by a moderator: