How to convert byte array to String

Hi I’m new to Arduino and I need some help with a problem I have.

Im trying to convert an array of byte to String and i just dont know how to go about it. I’ve searched online and found no solution can someone help.

So basically ive succesfully created a byte arry of a binary number:

(byte bin[7]

bit[0] = 1
bit[1] = 1)

can so on to create a binary number. now i need to combine the values of the array together and display as a string e.g. “00100111”

How would I go about it?

What i have so far:

byte number = 111;
byte mod ;
byte bin[7];
for(int i = 0; i < 8; i++){
while(number >= -128 && number <= 127){ //checks to see if number is in the range of -128 to 127
mod = number%2; //calculates the modulo of input / 2
bin = mod;

  • number /= 2; //divides input by 2*

  • int exit = mod + number;*

  • if(exit == 0){*

  • number = 1000; // checks to see if modulo + the current input is equal to 0 if so exit loop*

  • }*

  • }*

Here is the algorithm I’d use instead:

byte number = 111;
byte bin[7];

for (int i = 0; i < 8; i++)
{
  bin[i] = (number & (1 << i)) >> i;
}

sorry for the late reply but thanks really cut out a lot of code

The array is too short,

byte bin[7];

for (int i = 0; i < 8; i++)

better use

byte bin[8];

now i need to combine the values of the array together and display as a string e.g. "00100111"

I would be interested to know why you need/want to do this.