Seven segment LED for cathode

okay


digitalWrite(STCP_pin, LOW);
{
shiftOut(DS_pin, SHCP_pin, MSBFIRST,   dec_digits[(buf[i] & 0x0f)] | 0x80) // dp ‘on’
} else {
shiftOut(DS_pin, SHCP_pin, MSBFIRST, dec_digits[(buf[i] & 0x0f)]); // no dp
}
digitalWrite(STCP_pin, HIGH);

Obviously, you’re setting up the data with the high bit (dp) set when needed…
I didn’t look at all your code, because it’s not posted properly…

Yes sir. But that is not working. If I set dp over there, I am getting only dp and not the other digits. Instead of dec_digits[(buf[i] & 0x0f)] | 0x80), If I use dec_digits[(buf[i] & 0x0f)] | 0x01) this working fine.
I don’t know why dp is getting prioritization when I add to another digit.

Well, I’m guessing your dec_digits isn’t holding what you expected…

You could try putting a Serial.print in there temporarily, to see what’s coming in. Everything will slow down, but you can watch the data values as they’re processed.

Like I said, and I don’t think I’m alone… you should reformat your code in tags so people will read it.

Another way if you can’t spot the issue soon, is to minimalise your code to just a loop() that calls the display function - getting rid of all the fluff for now.

Then you’ll know what’s being generated, and what’s being displayed- finding the difference will be a lot easier.

I am posting the code again.
//int DS_pin = 7; // Data pin of 74hc595 connected to the 11th pin of Arduino Uno(7 for TPIC6C596)
//int STCP_pin = 6; // Latch pin of 74hc595 connected to the 12th pin of Arduino Uno(6 for TPIC6C596)
//int SHCP_pin = 5; // Clock pin of 74hc595 connected to the 8th pin of Arduino Uno(5 for TPIC6C596)
//int gpin = 4; // G pin of 74hc595 connected to the 4th pin of Arduino Uno(4 for TPIC6C596)
////int srclr = 8;
////int samplse = 0; // the first sensor value
//float sensorvalue = 1.49;
///* values that are assigned to the name of the macros /
////#define x1 0.564662421366142
////#define x2 1.22135167695223
//
///
7 segment common anode values ranging from 0 to 9 /
//int dec_digits [11] = {
// B00111111, //0
// B00000110, //1
// B01011011, //2
// B01001111, //3
// B01100110, //4
// B01101101, //5
// B01111101, //6
// B00000111, //7
// B01111111, //8
// B01101111, //9
//};
//
///
setup initializes serial and the pin settings /
//void setup()
//{
// Serial.begin(9600); // 9600 Baud Rate
// Serial.println(" Metal Width Detector\n ");
// //set pins to output
// pinMode(DS_pin, OUTPUT); // Setting Data Pin as an OUTPUT
// pinMode(STCP_pin, OUTPUT); // Setting Latch Pin as an OUTPUT
// pinMode(SHCP_pin, OUTPUT); // Setting Clock Pin as an OUTPUT
// // pinMode(srclr, OUTPUT);
// pinMode(gpin, OUTPUT); // Setting gPin as an OUTPUT
// digitalWrite(SHCP_pin, LOW); // Write Pin as LOW
// digitalWrite(DS_pin, LOW); // Write Pin as LOW
// digitalWrite(STCP_pin, LOW); // Write Pin as LOW
// digitalWrite(gpin, LOW); // Write Pin as LOW
// //digitalWrite(srclr, HIGH);
//}
//
///
loop checks the sensor state and will send serial after calibration /
//void loop()
//{
// // read the first sensor
// //int samplse = analogRead(6);
// /
map(value, fromLow, fromHigh, toLow, toHigh)
// map - maps a number from one range to another.
// value - the number to map.
// fromLow - the lower bound of the value’s current range.
// fromHigh - the upper bound of the value’s current range.
// toLow - the lower bound of the value’s target range.
// toHigh - the upper bound of the value’s target range.
// /
// //float sensorvalue = 1.23;
// updateDisplay();
//}
//
//void updateDisplay()
//{
// /
To print the values in the serial monitor, if necessary /
// Serial.println(sensorvalue, 2);
// char buf[10]; // A variable that contains char values
// /
dtostrf - This function converts the float values to the char.
// dtostrf(floatvar, StringLengthIncDecimalPoint, numVarsAfterDecimal, charbuf);
// floatvar - float variable
// StringLengthIncDecimalPoint - This is the length of the string that will be created
// numVarsAfterDecimal - The number of digits after the decimal point to print
// charbuf - the array to store the results
// /
// dtostrf(sensorvalue, 4, 2, buf);
//// Serial.println(buf[0]);
//// Serial.println(buf[1]);
//// Serial.println(buf[2]);
//// Serial.println(buf[3]);
// // Writing LOW on the STCP pin allows us to send data to the IC
// digitalWrite(STCP_pin, LOW);
// /
for loop execution /
// for (int i = 0; i <= 3; i++)
// {
// if (buf[i] != ‘.’)
// {
// if (buf[i + 1] == ‘.’)
// {
// /
shiftOut(dataPin, clockPin, bitOrder, value)
// shiftOut - Shifts out a byte of data one bit at a time.
// dataPin - the pin on which to output each bit. Allowed data types: int.
// clockPin - the pin to toggle once the dataPin has been set to the correct value. Allowed data types: int.
// bitOrder - which order to shift out the bits; either MSBFIRST or LSBFIRST.
// value - the data to shift out. Allowed data types: byte.
// converting the resultant char value to a decimal value.
// adding the decimal point wherever we want in the seven segment display
// */
// digitalWrite(STCP_pin, LOW);
// shiftOut(DS_pin, SHCP_pin, MSBFIRST, (dec_digits[(buf[i] - 0x30)])|0X80);
// //shiftOut(DS_pin, SHCP_pin, MSBFIRST, 0X80);
//
// delay(2000);
// digitalWrite(STCP_pin, HIGH);
// //Serial.println(dec_digits[i]);
// }
// else
// {
// digitalWrite(STCP_pin, LOW);
// shiftOut(DS_pin, SHCP_pin, MSBFIRST, dec_digits[(buf[i] - 0x30)]);
// delay(2000);
// digitalWrite(STCP_pin, HIGH);
// }
// }
// }
// // Writing HIGH on the STCP pin, no longer needs to listen for information
// digitalWrite(STCP_pin, HIGH);
//
// // waits for a second
// delay(1000);
//}

And you still have not done it properly

As previously requested, please post your code following the advice given in the link below

As per your guidelines, I gave used serial.println. my dec_digits is not holding my decimal point

But you still have not put your code in code tags

So what happens f you don’t add the dp, just use one condition (the first one)…
Does it display the digits ?

Yes it displays the same digit.

The ‘correct’ digits…???

What I’m trying to do is exclude anything that could possibly interfere.

Once you confirm that, we should try just displaying that 0x80 byte without any digits…
If that works, I’d start looking at your wiring.

Hi,
The code you posted will not even compile.

How does your code work if you COMMENT out the void loop() part of your code.

PLEASE READ THIS
To add code please click this link;

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Tom… :grinning: :coffee: :coffee: :coffee: :coffee: :coffee: :coffee: :australia:

Hi guys,
I am using TPIC6C596 shift register and this register is capable of sending 8 bits. When I start sending 8 bits, I am getting only the last bit (i.e decimal point).
But without the 8th bit (decimal point), my shift register can transfer whole 7 bits at a time.
May i get the solution for this?

Your duplicate topic on the same subject has been merged into this one

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a timeout from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky “How to use this forum - please read.” post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Both are different. Why you are merging it.

So that the full background to your project and problems with it are available without having to ask for them all over again

Hi,
I think I have an issue with the shift register.
am using TPIC6C596 shift register and this register is capable of sending 8 bits. When I start sending 8 bits, I am getting only the last bit (i.e decimal point). But without the 8th bit (decimal point), my shift register can transfer whole 7 bits at a time. May i get the solution for this? When I implement in the proteus I am getting proper output. while doing the same in the hardware, I face the issue. For example, 0b00000110, I am getting the value as 1. if i do, 0b00000110 | 0b10000000, I am getting only .(dot) without 1. I should get 1.(one + dot). shiftOut(DS_pin, SHCP_pin, MSBFIRST, dec_digits[(buf[i] - 0x30)]|0x80); What will be the issue.?

0r my doubt is when supply goes to decimal point, all the other pins goes to OFF condition.
When supply don’t go to the decimal point, all the other pins goes to ON condition.
Is that correct?

It’s time for you to show a circuit diagram… not a fritzy or blurry photo.

Can i send you in the mail address?