Some time ago i bought a 7 segment display, with 6 digits, controlled by 2 74hc595 chips.
I looked for some examples on the internet how to hook up 7segs displays, but that didn't make it clear. then i checked a few libraries and still couldn't make it work.
Link to the shop: https://robotdyn.com/catalog/segment/6_digit_led_display_tube_7_segments_74hc595/
If somebody could help me understand how to code my arduino or give a sample how to display useful things on this display, i would appreciate it very much.
[SOLVED] UPDATE:
So, with some hints and advice, I managed to display useful information on this display.
This piece of code is not nearly in a good shape, and there are definitely things to improve (which I may improve, if I have time). But still, this is enough to get things going.
// ST_CP = SCK
// SH_CP = RCK
// SDI = DIO
// Common anode
#define DS 10
#define STCP 11
#define SHCP 12
#define SPEED 500
boolean numbersDef[10][8] =
{
{1,1,1,1,1,1,0}, //zero
{0,1,1,0,0,0,0}, //one
{1,1,0,1,1,0,1}, //two
{1,1,1,1,0,0,1}, //three
{0,1,1,0,0,1,1}, //four
{1,0,1,1,0,1,1}, //five
{1,0,1,1,1,1,1}, //six
{1,1,1,0,0,0,0}, //seven
{1,1,1,1,1,1,1}, //eight
{1,1,1,1,0,1,1} //nine
};
boolean digitsTable[8][8] =
{
{0,0,0,0,1,0,0,0}, // first digit
{0,0,0,0,0,1,0,0}, // second
{0,0,0,0,0,0,1,0}, // third
{1,0,0,0,0,0,0,0}, // forth
{0,1,0,0,0,0,0,0}, // fifth
{0,0,1,0,0,0,0,0} // sixth
};
void setup() {
pinMode(DS, OUTPUT);
pinMode(STCP, OUTPUT);
pinMode(SHCP, OUTPUT);
digitalWrite(DS, LOW);
digitalWrite(STCP, LOW);
digitalWrite(SHCP, LOW);
}
boolean display_buffer[16];
void prepareDisplayBuffer(int number, int digit_order, boolean showDot)
{
for(int index=7; index>=0; index--)
{
display_buffer[index] = digitsTable[digit_order-1][index];
}
for(int index=14; index>=8; index--)
{
display_buffer[index] = !numbersDef[number-1][index]; //because logic is sanity, right?
}
if(showDot == true)
display_buffer[15] = 0;
else
display_buffer[15] = 1;
}
void writeDigit(int number, int order, bool showDot = false)
{
prepareDisplayBuffer(number, order, showDot);
digitalWrite(SHCP, LOW);
for(int i=15; i>=0; i--)
{
digitalWrite(STCP, LOW);
digitalWrite(DS, display_buffer[i]); //output LOW - enable segments, HIGH - disable segments
digitalWrite(STCP, HIGH);
}
digitalWrite(SHCP, HIGH);
}
void loop() {
writeDigit(0, 1);
writeDigit(2, 2, true);
writeDigit(3, 3);
writeDigit(4, 4, true);
writeDigit(5, 5);
writeDigit(6, 6);
}
Code can be easily adjusted to output letters and other things. For me - digits from 0 to 9 is enough.
I would like to express my gratitude to the guys who helped me. And I hope somebody may find this post useful.