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++)

void loop()
void up_count()
  convert=bintobcd(count);  //the error message appears in this line
  }           //up count loop ends here
  byte bintobcd(byte recv)
    byte q,r; //quotient,remainder
    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.