-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not understanding OF to arduino communication #71
Comments
Could you clarify this question with some code ... screenshots or other information? I'm assuming you have seen all of the examples in this repo? Using ASCII encoded strings: Using bytes rather than strings: |
Also, the video you found does things a slightly different way, so just keep that in mind when comparing. |
o i think i completely missed the week 6 simpleserialprotcol sketches. i was going off of this from the assignments page should i not use this code? // in void setup()
ofSerial mySerial;
mySerial.setup(); // fill in your data
// ...
// in void update()
ofBuffer outputBuffer;
outputBuffer.append(ofToString(VALUE_0));
outputBuffer.append(",");
outputBuffer.append(ofToString(VALUE_1));
outputBuffer.append(",");
outputBuffer.append(ofToString(VALUE_2));
outputBuffer.append("\r\n");
int numBytesWritten = mySerial.writeBytes(outputBuffer.getBinaryBuffer(), outputBuffer.size());
if(numBytesWritten != outputBuffer.size())
{
// warning ... something probably went wrong ...
} |
You can use either one. It depends on what kind of data you want. You can read the code / comments for a clear description of when you would want to use one vs. the other. The week six example just demonstrates another way of doing it (without ASCII encoding). |
cool thanks, it works. the week 6 sketches were more of what i was going for. the arduino is ok sending and receiving data simultaneously? |
*at receiving |
Yeah, the Arduino can do both at the "same" time. Of course it's not actually happening at the same time, because a |
ok just making sure its not a damaging process because my "arduino" is a "little" more expensive than a standard board. |
ive looked at the stackoverflow parsing string delimiter thing and im a bit confused. what would a basic arduino sketch for serial.read look like. i found a youtube video that makes more sense, but not enough.
http://www.youtube.com/watch?v=ts81ZTdY_DQ
also im getting errors in my OF code, it wants to change mySerial to eSerial and im getting an error of "member reference base type '<anonymous enum at /Applications/Xcode.app..... "
int numBytesWritten = mySerial.writeBytes(outputBuffer.getBinaryBuffer(),
The text was updated successfully, but these errors were encountered: