Azzera filtri
Azzera filtri

Arduino ReadDigitalPin all ones

1 visualizzazione (ultimi 30 giorni)
almolch
almolch il 4 Mag 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 Commento
Walter Roberson
Walter Roberson il 4 Mag 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?

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su MATLAB Support Package for Arduino Hardware in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by