1

I am attempting to send some information from MatLab to an Arduino Uno via Bluetooth with the following

MatLab program:

b=Bluetooth('HC-06',1);
fopen(b);
for i=1:1:15 
 fprintf(b,i); 
 out(i) = fscanf(b,'%d');
end
fclose(b)

and Arduino program

int matlabval=0;
void setup() {
 Serial.begin(9600); 
}
void loop() {
 if (Serial.available() > 0) {
 matlabval = Serial.read();
 Serial.println(matlabval); 
 }
}

the output of arduino is

1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 11 10 12 10 13 10 14 10 15 10

The number 10 appears after each number. Why is that so?

Thanks in advance!

zx485
2564 silver badges15 bronze badges
asked Apr 14, 2016 at 6:11
1
  • asciitable.com Decimal 10 is the ASCII code for a "New Line" so it appears your Matlab send code will add a "New-line" after each sent value. Commented Apr 14, 2016 at 8:15

1 Answer 1

1

As discussed in the comments, the "problem" seemed to be Matlab adding a "New Line" which is a decimal 10 in ASCII.

asciitable.com Decimal 10 is the ASCII code for a "New Line" so it appears your Matlab send code will add a "New-line" after each sent value. – Paul Apr 14 at 8:15

thank you very match the problem is solved – abbas hussien 5 hours ago

You might want to accept this answer so that this question gets "closed" and the site's statistics will be more accurate. It will also avoid this question being bumped up by the system and people reading into something that has already been solved.

answered Apr 17, 2016 at 14:52

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.