(ชิ้นงานที่4ของเดือน ก.ค)DC Motor Control Using MATLAB and Arduino

function varargout = DCmotor(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @DCmotor_OpeningFcn, ...
                   'gui_OutputFcn',  @DCmotor_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
function DCmotor_OpeningFcn(hObject, eventdata, handles, varargin)
guidata(hObject, handles);

function varargout = DCmotor_OutputFcn(hObject, eventdata, handles) 
varargout{1} = handles.output;
clear all;
global a;
a = arduino();

function clockwise_Callback(hObject, eventdata, handles)
global a;
writeDigitalPin(a, 'D5', 0);
writeDigitalPin(a, 'D6', 1);
pause(0.5);

function anticlockwise_Callback(hObject, eventdata, handles)
global a;
writeDigitalPin(a, 'D5', 1);
writeDigitalPin(a, 'D6', 0);
pause(0.5);

function stop_Callback(hObject, eventdata, handles)
global a;
writeDigitalPin(a, 'D5', 0);
writeDigitalPin(a, 'D6', 0);
pause(0.5);

ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

MATV