Borrar filtros
Borrar filtros

Arduino ReadDigitalPin all ones

1 visualización (últimos 30 días)
almolch
almolch el 4 de Mayo de 2018
Comentada: Walter Roberson el 4 de Mayo de 2018
Hi, I'm trying to connect an arduino to matlab to collect data from the digital pins. I am sending data to pin D3, but when I say readDigitalPin(a,'D3') in matlab it just gives me 1. My code is below, any advice would be appreciated.
if true
a = arduino('com8', 'uno');
t1 = 0;
dt=[];
dv=[];
tic
for i =1:500
i;
tic;
v = readDigitalPin(a,'D2');
dT = toc;
t1 = t1 + dT;
dt(i) = [t1];
dv(i) = [v]
pause(0.5)
end
end
  1 comentario
Walter Roberson
Walter Roberson el 4 de Mayo de 2018
Have you put an oscilloscope onto the pin to verify that the value goes lower than the threshold at some point, and does so for longer than the hold time of the sampling hardware?
Is D2 configured as a continual read or is it configured as triggered by edge detection? If triggered then what are the reset conditions?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by