I’m now trying to learn about the difference between OF and processing, one of the questions I have is how to use OF to send mouse position to arduino?
in processing we can simply do:
and split the strings in arduino,
Can I do the similar thing in OF too?
Thank you !
yes, but you need to use ofIntToString()
so you will do:
or… you can use the string . append fucntions etc…
string in c++ is more powerfull than string in processing!
hey k, thanks for the reply,
however the syntax of writeByte is writeByte(unsigned char * buffer, int length),
how can I do that?
ok, here is what I have tried so far
valX = ofGetMouseX();
valY = ofGetMouseY();
string newX = ofToString(valX);
string newY = ofToString(valY);
however I got an error “cannot initialize a parameter of type"unsigned char *” with an rvalue of type “char*” "
const char *buffer = dataPack.c_str();
and send the char pointer buffer.
in c++ we have many types of strings…
string is basically an array of characters (char)
a pointer in this case is like saying an array… a chunk of memory.
unsigned means that it can hold more data because it utilizes positive numbers thus giving you greater range
I our case you can also do
instead of string.
the reason why you cannot use string is merely because the object you are using was designed to use unsigned char…
it’s actually very easy to overwrite the writebytes function and make it use strings…