Seven segment interfacing, function not declared in scope error

byte a,pos,count,convert,bit_value,segment_pins[]={2,3,4,5,10,11,12,13};
void setup()
{
  for (a=0;a<=7;a++)

{
 pinMode(segment_pins[a],OUTPUT);
}
count=0;
}
void loop()
{
  up_count();
}
void up_count()
{
  convert=bintobcd(count);  //the error message appears in this line
  pos=7
  for(a=0;a<=7;a++)
  {
    bit_value=bitRead(convert,pos);
    digitalWrite(segment_pins[a],bitvalue);
    pos=pos-1;
  }
  delay(300);
  count=count+1;
  if(count==100)
  {
    count=0;
  }           //up count loop ends here
  byte bintobcd(byte recv)
  {
    byte q,r; //quotient,remainder
    q=recv/10;
    r=recv%10;
    q<<4;    //MSB shifted 4 spaces to left
    q|r;     //OR operator
    return q;
  }}
  }

error message:
‘bintobcd’ was not declared in this scope

This code is designed for a typical counter for counting from 0 to 99. However there is an error message for not declaring bintobcd. What change must I make in the top-most line for this program to work?

Edit: Autoformatting has removed the previous error. The new error message says:
‘bintobcd’ cannot be used as a function
What might be the problem here?

Your bintobcd() function is in the wrong place. check the {}

(indent the code and you’ll see it)

    q<<4;    //MSB shifted 4 spaces to left
    q|r;     //OR operator

?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.