Clear Filters
Clear Filters

Arduino ReadDigitalPin all ones

1 view (last 30 days)
almolch
almolch on 4 May 2018
Commented: Walter Roberson on 4 May 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 Comment
Walter Roberson
Walter Roberson on 4 May 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?

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB Support Package for 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!