8 bit binary code to text

Text to binary code:

void setup() {
  Serial.begin(9600);         // open serial port at 9600 baud

void loop() {
  if(Serial.available()) {    // if anything on port
    byte c = Serial.read();   // read one character
    for(int i=0; i<8; i++) {  
      Serial.print(c%2);      // print the least significant bit
      c /= 2;                 // move to next significant bit


I want to reverse this process. Help.
Binaty code in digital input to text ?


I think what you want to do is define the character instead of reading a character value. So delete the "byte c"line and in the header add a char definition.

char c = 'text';


char c = 'text';

This will not work.
In C/C++ "char" is just one single value.
You can use a character array, but you have to use double quotes instead of single ones and curly brackets.

char c[] = {"text"};

This array has 5 values (not 4) because it has a termination character (null character: 0x00) at the end.
The termination character is added automatically in this case.
For more detailed information see: string - Arduino Reference

And to the initial question: I am sorry, I don't understand what the thread opener wants to do.

Yeah I didn't understand exactly what the OP wanted to do too. You can use char(x) to turn a number into a character. So if byte() defines a number then that should be able to be used in char() to make a character. However, I might be totally off.