These codes run good with Visual C++6.0 but not run in Arduino ,
can you help me modify them.
Two options:
Get the source code for Visual C++6.0 and port it to your Arduino. If it requires Java, you will have to ask Sun as well. With that, you can recompile your code and it will run on Arduino; or
Understand what Arduino is and isn't and write your code for Arduino.
You can figure out for yourself which option is best for you.
There are probably better ways, but this is one example of how to convert a string of ascii characters to a string of their decimal equivalent:
char string[] = "This is a string of ASCII Characters";
char buffer[4*sizeof(string)]; //sized for the worst case scenario of each being in the hundreds plus a space between each and a null
char* buffPtr = buffer;
for(byte i = 0; i < sizeof(string) - 1; i++){
itoa((int)string[i],buffPtr,10); //convert the next character to a string and store it in the buffer
buffPtr += strlen(buffPtr); //move on to the position of the null character
*buffPtr = ' '; //replace with a space
buffPtr++; //move on ready for next
}
buffPtr--; //move back a character to where the final space (' ') is
*buffPtr = '\0'; //replace it with a null to terminate the string
Serial.println(buffer);
Hi Tom
I just tested your code ,it's good but no display the first character of string.
Examle : char string[] = "abcd";
Result : 98 99 100
not display 97 of "a"
Can you modify ?
Thanks .