Go Down

Topic: Sending text string to Arduino from Matlab (Read 3161 times) previous topic - next topic


I have been trying to send a text string from Matlab to arduino. I can send simple digit to the arduino [upto 3 digits; e.g. 123] but can not send more digits or text. Please help me understand the problem. I am new in programming. So here is the code for Matlab which worked for me to send digits:
Code: [Select]

clear all

answer=1; % I think here is the problem but don't know how to initialize it so that it will take text or longer digits
arduino=serial('COM4','BaudRate',9600); % create serial communication object on port COM4

fopen(arduino); % initiate arduino communication

while answer
fprintf(arduino,'%s',char(answer)); % send answer variable content to arduino
answer=input('Enter led value 49 or 50 (49=ON, 50=OFF, 0=EXIT PROGRAM): '); % ask user to enter value for variable answer

fclose(arduino); % end communication with arduino


Sorry for replying my own query. But if I had changed the
it would be possible to insert any text value. Hope someone would be benefited by this answer.


We really need to see how you recieve the data.

We also would like to know how you "know" that a large number was not sent - did you get an error code?

(After 26 posts you should know how to post a well formed question on this Forum)

Go Up