Unable to rotate motor using Arduino with the help of MATLAB

this is the code :

clear all;
clc;
clear a;
a=arduino('COM6','Uno');
m1='D10';
m2='D9';
configurePin(a, m1, 'DigitalOutput');
configurePin(a, m2, 'DigitalOutput');
for i= 1:20
    disp(i);
    writePWMDutyCycle(a,m1,0.75);
    %writeDigitalPin(a,m2,0);
    writePWMDutyCycle(a,m2,0);
    disp("forward");
    pause(2);
    writePWMDutyCycle(a,m1,0);
    writePWMDutyCycle(a,m2,0.75);
    disp("backward");
    pause(2);
end

this is the error massage that i am getting all the time even after using "writeDigitalPin" too. Please help.
Error using v1 (line 15)
Unable to receive data from the target hardware.
For MATLAB, reconnect the target hardware, clear the hardware objects and try again.
For Simulink, reconnect the target hardware and start simulation again.

Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

It also has nothing to do with Arduino as far as I can see beyond connecting to a Uno

did you confirm you are connected to your arduino thru the correct COM port?

1 Like

yess.. and sometimes I am getting errors like this--
1

forward
Error using v1 (line 22)
Unable to receive data from the target hardware.
For MATLAB, reconnect the target hardware, clear the hardware objects and try again.
For Simulink, reconnect the target hardware and start simulation again

u trying what Matlab helps suggested for this error...?

didn't understand what are you asking?.....Let me tell you...the MATLAB version i am using is 2021a. The error massage provided above is what i am getting on the command window...and... i did not get any suggestion from the MATLAB in the command window. When i searched this massage in the internet...i got something like troubleshooting sensors, i followed those steps, but the problem remains same ( error massage of the command window is still the same.).

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.