Matlab Arduino Using analog inputs as outputs -
Matlab Arduino Using analog inputs as outputs -
i need utilize arduino analog inputs digital outputs a0 a1 a2 a3 a4 a5. digitalwrite(a0, 0) doing job when utilize arduino programme in matlab couldnt find way this.i tried if a0 taken 14 digitalwrite(14, 0) , didnt work. know how pin mapping thing in matlab? briefly equal of digitalwrite(a0, 0) in matlab?
function test_openingfcn(hobject, eventdata, handles, varargin) % take default command line output test handles.output = hobject; % update handles construction guidata(hobject, handles); global a; set(handles.pushbutton1, 'userdata', 0); a=arduino('com3'); a.pinmode(2,'output'); a.pinmode(3,'output'); a.pinmode(4,'output'); a.pinmode(5,'output'); a.pinmode(6,'output'); a.pinmode(7,'output'); a.pinmode(8,'output'); a.pinmode(9,'output'); a.pinmode(10,'output'); a.pinmode(11,'output'); a.pinmode(12,'output'); a.pinmode(13,'output'); a.pinmode(14,'output');
function pushbutton1_callback(hobject, eventdata, handles) global a; global counter; counter = get(hobject, 'userdata') + 1 set(hobject, 'userdata', counter); if(counter==1) a.digitalwrite(14,1);this doesnt work a.digitalwrite(7, 0); a.digitalwrite(13, 0); a.digitalwrite(8, 1); a.digitalwrite(12, 0); a.digitalwrite(9,0); a.digitalwrite(11, 0); a.digitalwrite(10, 0); a.servostatus(2) end
you right in assuming a0 equivalent pin 14, code should work. perhaps forgot set pin mode? can post code , error got?
the next code works me:
= arduino('com4'); a.pinmode(14,'output'); % pin 14 equivalent analog pin a0 tic; while toc/60 < 0.25 % run 15 seconds a.digitalwrite(14,1); % setting a0 high end delete(a); clear a;
matlab arduino
Comments
Post a Comment