control dc motor speed
조회 수: 5 (최근 30일)
이전 댓글 표시
I have following code to control DC motor through H-Bridge and Arduino :
function motor_control2_OpeningFcn(hObject, eventdata, handles, varargin)
a = arduino('com3');
handles.a = a;
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to motor_control2 (see VARARGIN)
% Choose default command line output for motor_control2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes motor_control2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = motor_control2_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.a;
% --- Executes on button press in forwardpushbutton1.
function forwardpushbutton1_Callback(hObject, eventdata, handles)
handles.a.pinMode(9,'output');
handles.a.pinMode(10,'output');
handles.a.pinMode(3, OUTPUT);
handles.a.digitalWrite(9,0)
handles.a.digitalWrite(10,0)
handles.a.analogWrite(3,200) % control the speed 0- 255
Pin 3 is the enablepin which i can control the speed of motor.Now,i have a question, can i just adjust the speed using slider in GUI? How can i do that?I have the analog write value from 0 - 255 to adjust the speed, then i wish to adjust the speed when my motor move using slider. Any expert can help me?thanks
댓글 수: 1
Nazrin Zaini
2014년 10월 22일
i want to ask the same question,so did you got the solution?if you dont mind can you share the solution.
답변 (1개)
커뮤니티
더 많은 답변 보기: Power Electronics Community
참고 항목
카테고리
Help Center 및 File Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!