Take the 2-minute tour ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

I am doing some computations on Matlab and I need to send those values to an Arduino Leonardo through USB serial connection. I need to send 2 variables which can vary from -400 to +400. I'm saying their values because I was able to do this with small positive values (unsigned byte), but not larger and negative numbers. Please help! Thank you

share|improve this question
2  
Consider sending printable values just as if you had typed them into the serial monitor. It is not the most efficient solution, but it is one of the simplest, avoiding the format-matching and synchronization challenges of multibyte binary data. –  Chris Stratton Feb 13 at 7:20
    
I am analyzing images from webcam and continuously sending data to Arduino. I solved the part of sending data, but the problem is that the Serial.Available() is updated only once. It receives much of the data as one string. I need it to be updated after every sending from Matlab. There is no interrupt with each serial fprintf basically. –  Martin V Feb 17 at 23:13
    
Communications on the leonardo is packetized, so data will arrive in chunks that may or may not match your initial message size. –  Chris Stratton Feb 17 at 23:17
    
Turns out Matlab needed me to define a '\n' terminator in the serial fprintf function along with the type of data to be transferred. The problem was solved, thank you for the help. –  Martin V Feb 18 at 23:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.