We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Dear all,
I am busy with a project and I am sending data from arduino to processing with UDP. I want to store the received data in a variable on the processing side but the example just prints the data. How can I save the printed value in a variable instead of only printing it?
void receive( byte[] data ) { // <-- default handler
// void receive( byte[] data, String ip, int port ) { // <-- extended handler
for(int i=0; i < data.length; i++)
print(char(data[i]));
println();
}
This is the code used ^
kind regards
Rens
Answers
If you printed the variable... then can't you just use the same parameters to save the values to a variable?
Kinda like this?:
I don't know whether you need a global variable or not, and whether your datatype is definitely char, but all of these are assumptions.
ah that seems easy enough i´ll give it a try! thanks for your help
huh if I use the variable i in the for loop twice e.g.
I get this error: Cannot find anything named "i"
full code:
You've forgotten to define the
for
loop block w/ curly braces! I-)It's necessary when we got more than 1 statement block! :-\"
Anyways, I've tweaked your code. It's untested since I don't have that 3rd-party library! :-/
But you can at least try it out for yourself: