Hello everyone.
For my design project, I want to send both negative integers and integers bigger than 255 to arduino from matlab. However, I can only send integers between 0 and 255.
I have searched the forum and could find a couple of topics related to my question but I am not able to implement those solutions in my codes. If you can help me, I wiil be ver happy. Here are my matlab and arduino codes:
Arduino code:
int arrayy[4];
int i=0;
void setup() {
Serial.begin(9600);
}
void loop() {
i=0;
if(Serial.available()>0){
matlabData=Serial.read();
arrayy*=matlabData;*
_ Serial.println(arrayy*);_
_ i++;_
_}_
Matlab code:
arduino = serial('COM6','BaudRate',9600);
fopen(arduino);
S(1)=-79;
S(2)=79;
S(3)=79;
S(4)=-79;
for i=1:4
_ fprintf(arduino,'%s',char(S(i)))_
_ a(i)=fscanf(arduino,'%d')*_
end
disp(a);
And I read 0 79 79 0 from matlab. Could you please help me?