arduino-adafruit shild - readDigitalPin func
조회 수: 1 (최근 30일)
이전 댓글 표시
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
2015년 4월 27일
sagie - which function call is generating this error: the move or the readDigitalPin?
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Arduino Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!