Go Down

Topic: HELP: 2 7 segment display (0-F) using 74LS595 shift register with 8 bit inputs (Read 3179 times) previous topic - next topic

CrossRoads

I see now - I had misread what the bitWrite was doing. The array only holds the pin numbers, not the actual result.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

glenn_boy13


Well you didn't read the sticky or your code would be in code tags. Yes, it's a big thing. A really big thing.


Thanks sir Nick. I was talking about the 5-hour thing and about my "UP" reply. noted.


If you have 4 switches, one option is to convert those 4 inputs into a number:
Code: [Select]

BCD_number = 0; // clear the variable to start
BCD_number = digitalRead(Din);  // result is 0 or 1
BCD_number = BCD_Number <<1 + digitalRead(Cin); // shift over 1 bit, and add in next bit
BCD_number = BCD_Number <<1 + digitalRead(Bin); // shift over 1 bit, and add in next bit
BCD_number = BCD_Number <<1 + digitalRead(Ain); // shift over 1 bit, and add in next bit
Serial.println (BCD_Number, DEC); // check the result

// Now use your display mapping:
shiftout(dataPin, clockPin, MSBFIRST, numbers[BCD_number] ); // lookup the mapping in the array and send it to the shift register
 




Thank you so much sir! By the way, I just have to
add this:
BCD_number = BCD_Number <<1 + digitalRead(Din); // shift over 1 bit, and add in next bit

and then copy-paste all these lines to the loop function, right?

Also, is there anything else I need to modify in the codes to display two hex digits in two 7 segment display? How am I suppose to connect the second shift register to the first one?
Never argue with stupid people, they will drag you down to their level and then beat you with experience.
-mt

CrossRoads

Yes, read the switches, make the result into a number.
Use the number to look up the character you want to send out.
Shift registers connect like this.
I don't know if your mapping has 1 = on for a segment, or if your display uses common cathode or common anode parts.
With common cathode, 1 = on for a segment. WIth common anode, 0 = on for a segment.
Don't forget the caps on the +5V pin for reliable operation.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up