Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: LX_Thunder on Dec 20, 2013, 01:39 pm

Title: Again 74HC195 and shiftIn()
Post by: LX_Thunder on Dec 20, 2013, 01:39 pm
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
int Mask = B00000000;
int Status = B00000000;

void setup() {
 //start serial
 //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
 //set clock high because of a bug in the SR
 // wait
 //set it to 0 to transmit data serially  
 // read form 4021
 Mask = shiftIn(dataInPin,clockInPin,MSBFIRST);
 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.
Title: Re: Again 74HC195 and shiftIn()
Post by: LX_Thunder on Dec 20, 2013, 01:58 pm
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.