arduino-adafruit shild - readDigitalPin func
1 view (last 30 days)
Show older comments
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 Comment
Geoff Hayes
on 27 Apr 2015
sagie - which function call is generating this error: the move or the readDigitalPin?
Answers (0)
See Also
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!