String text ="";
int base = 2; // base of number system of textstring

unsigned long binaryTexttoDecimal(String BinaryText);

void setup() {
Serial.begin(9600);
text ="1111000";

Serial.println(text);
Serial.println(binaryTexttoDecimal(text));
Serial.println(binaryTexttoDecimal(text),BIN);
//Serial.println(BinCharToInt('1'));
//Serial.println(BinCharToInt('0'));
//Serial.println(binaryTexttoDecimal("10001"),BIN);

text = String(1011011);
//text = String(1111000);
Serial.println(text);
Serial.println(binaryTexttoDecimal(text));
Serial.println(binaryTexttoDecimal(text),BIN);

}

void loop() {
  // put your main code here, to run repeatedly:

}

unsigned long binaryTexttoDecimal(String BinaryText)
{
  int textSize = BinaryText.length();

  long int Value = 0;
  for(int i=0; i<textSize; i++)
  {
    Value = Value*base + BinCharToInt(BinaryText.charAt(i));
  }
  
  return Value;
}

int BinCharToInt(char BinaryChar)
{
    if(BinaryChar == '1')
      return 1;
    else 
      return 0;  
}