arduino-adafruit shild - readDigitalPin func

1 visualización (últimos 30 días)
sagie meshulam
sagie meshulam el 25 de Abr. de 2015
Comentada: Geoff Hayes el 27 de Abr. de 2015
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 comentario
Geoff Hayes
Geoff Hayes el 27 de Abr. de 2015
sagie - which function call is generating this error: the move or the readDigitalPin?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Arduino Hardware en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by