Hi, I am using the MATLAB Support Package for Arduino (aka ArduinoIO Package)to run a stepper motor and read voltages. I am trying to run a stepper motor using a seeedstudio motor shield v1.0 paired with an arduino uno, and it is totally fine running the stepper in the arduino IDE but I haven't managed to budge it using MATLAB. I have been successful moving servos and reading analog voltages through MATLAB, so maybe the problem is the motor shield?
My code is below, adapted from one found here: http://www.seeedstudio.com/wiki/Motor_Shield_V1.0
function[]=stepperattempt() %stepperattempt %A program to sweep a stepper back and forth using Arduino I/O package
clear all;
a=arduino('/dev/tty.usbmodem3d11'); %creates arduino object
tlen=30;
spr=200;
a.stepperSpeed(1,60);
a.pinMode(9,'OUTPUT'); a.pinMode(10,'OUTPUT'); a.digitalWrite(9,1); a.digitalWrite(10,1);
for i=1:tlen
a.stepperStep(1,'forward','double',spr);
pause(.5);
a.stepperStep(1,'backward','double',spr);
pause(.5);
enda.delete(); %ALWAYS DO THIS
end
The problem with this code is that the stepper did not move, and entering command line, um, commands doesn't move it either.
Any help would be greatly appreciated!
No products are associated with this question.
0 Comments