MATLAB Arduino limit switch

5 views (last 30 days)
Raguvaran Veerappan
Raguvaran Veerappan on 24 Feb 2018
Commented: Georgi Rahnev on 10 Oct 2021
Hi, i would like to know how do I program the Arduino which controls a small DC motor. What I would like is for the motor to move in 1 direction and when the limit switch is hit the motor stops.
As of now, i cannot seem to get the for loop to work. I'm not sure if the read function is been sent to the loop. hope someone could help me. thanks in advance.
function rto_Callback(hObject, eventdata, handles)
global a
value=readDigitalPin(a, 'D11');
if (value==0)
writeDigitalPin(a, 'D8',1);
writeDigitalPin(a, 'D9',0);
else if (value==1)
writeDigitalPin(a, 'D8',0);
writeDigitalPin(a, 'D9',0);
% break
end
end
  15 Comments
Yong Mun Pok
Yong Mun Pok on 12 Apr 2019
To Ragu,
Can you share the working code. It will really help me in doing my project. Otherwise, can send the relevant info the my email munson0829@gmail.com
Georgi Rahnev
Georgi Rahnev on 10 Oct 2021
I will be also thakful if you share. the_sooner@yahoo.com

Sign in to comment.

Answers (0)

Categories

Find more on Arduino Hardware in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!