Effacer les filtres
Effacer les filtres

Arduino ReadDigitalPin all ones

1 vue (au cours des 30 derniers jours)
almolch
almolch le 4 Mai 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 commentaire
Walter Roberson
Walter Roberson le 4 Mai 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?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur MATLAB Support Package for Arduino Hardware dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by