hi
I want to use the Matlab to control a dc motor with monster moto shield VNH2SP30, I use this shield and control the dc motor with Arduino program but with Matlab, it does not work my code in Matlab is:
JohnLincoln:
Is there some kind of sketch loaded on to the Arduino, that is meant to understand what those Matlab commands mean?
actually, writeDigitalPin(a,'D7',1) in the Matlab is same as digitalWrite(7, HIGH) in the Arduino program and I write this code because of the monster moto shield attached to the arduino board and digital pins 7 and 8 are INA and INB of dc motor
koronus:
actually, writeDigitalPin(a,'D7',1) in the Matlab is same as digitalWrite(7, HIGH) in the Arduino program and I write this code because of the monster moto shield attached to the arduino board and digital pins 7 and 8 are INA and INB of dc motor
I thought that would be the case.
Do you just connect a brand new arduino up to your motor motor shield and it will work straight away? ( I don't see how that could happen).
Or do you have to have to load some kind of sketch onto the Arduino to enable it to operate in conjunction with Matlab?
Have you been able to control other items such as the LED connected to pin 13 of the Arduino?
Do you just connect a brand new arduino up to your motor motor shield and it will work straight away? ( I don't see how that could happen).
Or do you have to have to load some kind of sketch onto the Arduino to enable it to operate in conjunction with Matlab?
Have you been able to control other items such as the LED connected to pin 13 of the Arduino?
I add the plugin of Arduino to Matlab and I test the other item and I could control the brightness of LED but for the monster moto shield, it does not work!
This is the suggested code structure, your code looks like it is missing some statements.
% create an arduino object
a = arduino('com3', 'uno');
% start the loop to blink led for 10 seconds
for i = 1:10
writeDigitalPin(a, 'D11', 1);
pause(0.5);
writeDigitalPin(a, 'D11', 0);
pause(0.5);
end
% end communication with arduino
clear a
When you run it in Matlab, Matlab will load this code to the UNO.
This is the suggested code structure, your code looks like it is missing some statements.
% create an arduino object
a = arduino('com3', 'uno');
% start the loop to blink led for 10 seconds
for i = 1:10
writeDigitalPin(a, 'D11', 1);
pause(0.5);
writeDigitalPin(a, 'D11', 0);
pause(0.5);
end
% end communication with arduino
clear a
When you run it in Matlab, Matlab will load this code to the UNO.
Tom... :)
thanks for your answer but, this code is for looping and it does the blinking 10 times and if you want to do it just for one time (for example turn the led on ) you can use these 2 lines code: