serial non ascii encoded
Hi I've been trying to run the Plolulu 8 servo from Max. I have been doing this with Arduino but have come across a few problems. I'm trying to sync 6 servos to every frame of a quicktime. while I've had success with 3 when I use 6 the serial commands don't seem to be keeping up ( I'm limited to 9600 with Arduino's Softserial ) Is it possible to send byte packages that are not ascii encoded, so I can directly program the servos from Max.
Any pointers would be greatly appreciated.
Kind regards Conor
Serial speaks through 8-bit bytes. ASCII is just a way of interpreting those bytes. If you just want to send raw numbers, you can do that as long as they are
if (Serial.available() > 0) {
// get incoming byte:
char svalue = Serial.read();
}
The tricky part is working out a proper communication protocol with this raw stream of bytes. The MIDI protocol (for all its quirks) can be a good model for creating a meaningful stream of bytes. Another idea would be to come up with a simple call/response function like:
char scount = 0;//how many bytes
Serial.write(99);//"99" is our arbitrary request byte
while(scount
if(Serial.ready>0){
svalue[scount]=Serial.read();
scount++;
}
}
And then on the Max side wait for a 99 byte to come over serial and then send along your bytes.
Best,
Andrew B.