arduino-adafruit shild - readDigitalPin func

조회 수: 1 (최근 30일)
sagie meshulam
sagie meshulam 2015년 4월 25일
댓글: Geoff Hayes 2015년 4월 27일
hello, im working on a project Including arduino-adafruit motor shild and a stepper motor.
I attached a hall efect sensor to the arduino (at pin 2) and a magnet to the motor, now i want that the motor will stop moving when the magnet is aboce the senor.
I checked it through matlab and the arduino gets feedback from the sensor just fine. my problem is that when im Writing it on a loop, it wont let me read the pin more than once.
here is the code
a = arduino('com4', 'uno', 'Libraries', 'Adafruit\MotorShieldV2');
switch_check=readDigitalPin(a,2);
sm=Rotate();
for i=1:200
if switch_check==1 %depends on the switch (normally open or normally closed
move(sm,1);
switch_check=readDigitalPin(a,2);%problematic, need to check why!!!
else
disp('the pin is 0')
end
end
and this is what i get after one time the loop is running
"Instrument object OBJ is an invalid object."
i can really use your help thank you
  댓글 수: 1
Geoff Hayes
Geoff Hayes 2015년 4월 27일
sagie - which function call is generating this error: the move or the readDigitalPin?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Arduino Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by