Im working on a project that implement the Direct Sequence Spread Spectrum using 2 Arduino Uno , a RF transmitter and a RF reciever.
I realized a basic RF communication between modules and now i have to implement the DSSS.For that i have to convert my message to binary.
For example , lets say the message is "Hi"
I declared my message like this:
const char * msg = "Hi";
I need to convert this message into his binary value which is "01001000 01101001 " and store it in another char.
I know you can convert it with "Serial.println(msg*, BIN);" but this option doesnt save the binary value.* I need to save into binary format because after that , i have to make a XOR betweeen every 0 or 1 and another binari code like "10100" Ex. 0 1 0 0 1 0 0 0 0 1 XOR
*10100 10100 10100 10100 10100 10100 10100 10100 10100 10100 * I hope you can understand what am i asking and i hope anyone can help me with this
**3.** To save the ASCII codes/values of Hi (01001000 01101001 = 0x4869) into single variable, the following codes could be executed:
const char *msg = "Hi";
int y1 = (int) * msg << 8; //y1 = 0100100000000000
msg++;
int y2 = (int) * msg; //y2 = 0000000001101001
int y = y1 | y2; //y = 0100100001101001
This method works for a short text like "Hi".What i need is a method to convert longer text into binary format because i need to make a XOR operation between the string of 1 and 0 and a code called Pseudonoise.
What we are trying to tell you, is that text is already stored in binary format. Everything is. If there is some special kind of binary format that you need, you have to explain it better. I'm sure almost any contributor to this forum could show you how to 'xor' characters with a noise function, if you post some code examples and fully explain what you want to do.
I need to convert this message into his binary value which is "01001000 01101001 " and store it in another char.
If you mean store in another char array, the function to use is strcpy() or strncpy(). I don't see how you can copy it to a fixed length data type because strings are inherently variable length.
aarg:
What we are trying to tell you, is that text is already stored in binary format. Everything is. If there is some special kind of binary format that you need, you have to explain it better. I'm sure almost any contributor to this forum could show you how to 'xor' characters with a noise function, if you post some code examples and fully explain what you want to do.
If you mean store in another char array, the function to use is strcpy() or strncpy(). I don't see how you can copy it to a fixed length data type because strings are inherently variable length.
Ok , im gonna try to be more explicit.I have a text that i need to convert every character of that text into his ASCII binary value(ex 01001000 is the ASCII code of H.). After that i have to store ASCII binary values because i need to make XOR between every bit of the converted string and a pseudonoise code of about 5 bits for example.
It still does not make any sense. Why would anyone do something as mad as converting a binary value into text in order to XOR it? And what is supposed to happen with the string after that? Converted back to binary?
Look at this:
uint8_t H = 72; //ASCII = 'H', binary = 01001000
//XOR with 11111111 to flip all bits:
H ^⁼ 0b11111111;
Serial.println(H, DEC); //Prints 183
Serial.println(H, BIN); //Prints 10110111
If you would want to flip all bits in the string "ABC", then the sollution would be:
char ABC[] = "ABC";
for (int i = 0; i < strlen(ABC); i++) ABC[i] ^= 0b11111111;
This is as simple as it gets, no conversion needed.
I'm not going to spend a lot of time to watch an educational video for something I do not need to know. What I did see was that I've told you exactely how to do what happens in the video in #8. If, for instance, you would want to transform 8 bytes with the (expanded) bits from one byte, that would look like this:
I think whis method worked , but now i have the following problem.How can i make a XOR between each bit and a pseudonoise ( a sequence of 0s and 1s ) ?