Some of you have had the pleasure of working with the CD4021 Par->Ser and i've looked closely
at the other forum posts of people having trouble this IC, to no prevail.
I've attached a pic of the breadboard I made to test the IC and the shiftIN functionality.
code is fairly simple but for the sake of it:
int inLatchPin = 2;
int inDataPin = 4;
int clockPin=3;
byte inData=0;
void setup(){
pinMode(inLatchPin,OUTPUT);
pinMode(inDataPin,INPUT);
pinMode(clockPin,OUTPUT);
Serial.begin(9600);
}
void loop(){
digitalWrite(inLatchPin,HIGH);
delayMicroseconds(20);
digitalWrite(inLatchPin,LOW);
inData=shiftIn(inDataPin,clockPin,MSBFIRST);
if (inData>0){Serial.println(inData);}
}
As you can see in the pic, I pulled down all inputs (yes +/- of both sides of BB are bridged) with a 10k resistor which is how it's explained in the Arduino Tutorial, and this should return "0"s , but for some reason it still returns "16".
Which means that Q5 is somehow stuck?
ps: I actually was working on a PCB with buttons and pulldowns and there I get a "7" (different 4021).
Made some adjustments to the setup to get the wires as short as possible.
Bridged the 5v/GND with a cap, bought 2 new CD4021's just to be sure.
The other 47uF (barely visible) on the +/- lines is something I found again on the internet in an article about de-coupling.
What I'm getting now is erratic changing numbers, sometimes, or "100".
4 of the pins seem to be working ok in the sense that using a button on PI 1 to 4 give me they give
me the right binary place, but with "100" behind it. So "1100" for PI 1, "10100" for PI 2 etc...
Going to try the other way later, putting 5V with resistor on the PI's and have it get the 0's instead.
Also bought a 7805 , maybe I should try get my 5v from another source...?
Most likely is a poor connection somewhere on the solderless (some call it contactless) breadboard. When a thin legs of i.e. resistors are in the same row as thick legs of other component the contact on resistor legs may be poor. What it worse it may be intermittent and change with slight movement of the components, breadboard or simply random. The more you use the breadbord the worse it is and soon you spend more time looking for a poor connection than building the circuit...
Smajdalf:
Most likely is a poor connection somewhere on the solderless (some call it contactless) breadboard. When a thin legs of i.e. resistors are in the same row as thick legs of other component the contact on resistor legs may be poor. What it worse it may be intermittent and change with slight movement of the components, breadboard or simply random. The more you use the breadbord the worse it is and soon you spend more time looking for a poor connection than building the circuit...
Hmm, didn't think of that.
Guess I'll start making a stripboard then, which means I'll need to buy some of those tiny caps called SMD's ?
or can I just put the normal caps on the flip side of the strip board...?
UdoVR:
3. I saw others use them too with Arduino/Genuino/....
Which follows.
While it is true that the functions in the Arduino IDE do tend to slow the logic to the speed of the original CD4000 series, you should be using the proper 74HC4021 or 74HC165.
Paul__B:
Sadly, a singularly poor recommendation!
Which follows.
While it is true that the functions in the Arduino IDE do tend to slow the logic to the speed of the original CD4000 series, you should be using the proper 74HC4021 or 74HC165.
Boy , my electronics dealer is gonna love me , huhu. Thanks for the advise...