Timeline for Convert Binary to char
Current License: CC BY-SA 4.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 30, 2020 at 14:03 | vote | accept | guyd | ||
| Jul 30, 2020 at 9:42 | answer | added | Majenko | timeline score: 2 | |
| Jul 30, 2020 at 9:40 | comment | added | Juraj♦ |
the point is, specially write does no conversion. print converts a number to text representation, by decomposing it to digits and mapping every digit to ascii.. so from a byte with value 123 it prints string "123" consisting of characters '1', '2', '3'. but write sends 123 as t is and Serial Monitor prints the character with this value, which is '{'.
|
|
| Jul 30, 2020 at 9:05 | comment | added | chrisl | You need to provide the full code, where you only got a bunch of numbers. Its all about, how you are writing or printing it to Serial. A character can also be interpreted as a number, so likely you are just outputting it to Serial the wrong way. | |
| Jul 30, 2020 at 9:01 | comment | added | guyd | @chrisl - I'm trying to exrract the text. When I did as you explained... I only got a bunch of numbers | |
| Jul 30, 2020 at 8:59 | comment | added | chrisl |
It is unclear, what you are trying to do. Binary and characters are just different representations of the same data. Serial.write() just sends the data out as it is and the Serial monitor then interprets that data as ASCII. But the Arduino does not care about, what the data represents. For the Arduino, everything is just binary data. The character interpretation is only for us humans and is done in the Serial monitor, not on the Arduino. So, when you want to put the data into a char array, just do so array[position] = myFile.read().
|
|
| Jul 30, 2020 at 8:53 | history | asked | guyd | CC BY-SA 4.0 |