Seven segment code

Here I am using the arduino code. I want to display my numbers with dot.
but unfortunately I am not getting this.
am using Seven segment cathode display. I need to display 1., 2., 3., 4., etc. When i do coding like B00111111 | B10000000, this should display as 0. (zero+dot)
But I am not getting this result. I am getting only ‘.’ (dot)
Help me?

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 samplse = 0; // the first sensor value
float sensorvalue = 4.9;
/* 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(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

/* 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;

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);
// Writing LOW on the STCP pin allows us to send data to the IC

/* 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] & 0x0f)] | 0x80);
digitalWrite(STCP_pin, HIGH);
digitalWrite(STCP_pin, LOW);
shiftOut(DS_pin, SHCP_pin, MSBFIRST, dec_digits[(buf[i] & 0x0f)]);
digitalWrite(STCP_pin, HIGH);
// Writing HIGH on the STCP pin, no longer needs to listen for information

// waits for a second

A post was merged into an existing topic: Seven segment LED for cathode