Go Down

Topic: Again 74HC195 and shiftIn() (Read 1 time) previous topic - next topic

LX_Thunder

Dec 20, 2013, 01:39 pm Last Edit: Dec 20, 2013, 01:51 pm by LX_Thunder Reason: 1
First of all I like to introduce myself. I just recently started with Arduino, mainly because of an Open Source project with Brushless Gimbals.
I have a mechanical engineering background and I know a little bit about electronics but just the basics, so forgive any dumb questions in this area. In terms of programming my skills are also very low, I would rather call it scripting than programming.

And this is the reason why I post my first question here.
"Has anyone successfully used the 74HC165 with the build in shiftIn() routine?"
I had a setup with the CD4021 that worked perfect but now I have a bunch of 74HC165 chips for another project and I cant get it to work. This is what I used
Code: [Select]

//define where your pins are

int clockInPin = 5;
int latchInPin = 6;
int dataInPin = 7;


//Define variables to hold the data
//for each shift register.
//starting with non-zero numbers can help
//troubleshoot
int Mask = B00000000;
int Status = B00000000;


void setup() {
 //start serial
 Serial.begin(9600);
 //define pin modes
 pinMode(latchInPin, OUTPUT);
 pinMode(clockInPin, OUTUT);
 pinMode(dataInPin, INPUT);

}

void loop()
{
 //Pulse the Input pin:
 //set it to 1 to collect parallel data
 digitalWrite(latchInPin,HIGH);
 delayMicroseconds(20);
 //set clock high because of a bug in the SR
 digitalWrite(clockInPin,HIGH);
 // wait
 delayMicroseconds(20);
 //set it to 0 to transmit data serially  
 digitalWrite(latchInPin,LOW);
 // read form 4021
 Mask = shiftIn(dataInPin,clockInPin,MSBFIRST);
 digitalWrite(latchInPin,HIGH);
 if (Mask != 0)
   {
  Status = Status ^ Mask;
  Serial.println ("---------");
  Serial.println (Status);
  Serial.println ("---------");
  delay (50);

  }
}


As I said, it worked great with the 4021 but when I tried it with the 74HC165 I have no success. Maybe I am to noob to read datasheets but here is how I wired up the chip:

latch on Pin 1
clock on Pin 2
data on Pin 9
6V on Pin 8
GND on Pin 8
Pin 15 on GND
The Input pins with a 10KOhm accordingly.

Any help would be highly appreciated.
Alex

LX_Thunder

Found it. I used a bad sketch where the latch and clock pin was declared as Input.
I edited my code post to the right code, because it would perhaps confuse people.

Go Up