Hi everyone,
I'm really sorry if this is a basic question, but I have been searching for hours and found nothing.
I am trying to turn a string into binary data and then convert it back into characters. The code for turning it into a string of binary numbers was pretty easy, so I would imagine that it would be similarly easy to turn it back into characters.
Code for string to binary:
String myText = "Hello world";
for(int i=0;i<myText.length();i++){
String out;
char myChar = myText.charAt(i);
for(int i=7;i>=0;i--){
int num = bitRead(myChar,i);
delay(100);
out += num;
}
Serial.println(out);
}
I have tried countless methods to try and print "out" as a character, but none seem to work.
Have I missed something? Is there a way of doing this?
From reading around other posts it seems you're supposed to print it as a char, but that only outputs numbers, not the letters I originally put in.
Many thanks,
Sam