Need help to see if the two codes I fused together are correctly placed

4 vues (au cours des 30 derniers jours)
Batuhan Yildiz
Batuhan Yildiz le 12 Nov 2022
clear all; close all;
a = arduino('/dev/tty.SLAB_USBtoUART', 'uno')
tic
max_samples = 1000;
tic
for i = 1:max_samples
sound_data(i) = readVoltage(a,'A2')
time_data(i) = toc;
end
plot(time_data, sound_data)
figure
h = animatedline;
ax = gca;
ax.YGrid = 'on';
ax.YLim = [-0.1 5];
title('Sound sensor voltage vs time (live)');
ylabel('Time [HH:MM:SS]');
xlabel('Voltage [volt]');
stop = false;
startTime = datetime('now');
while ~stop
voltage = readVoltage(a,'A2');
t = datetime('now') - startTime;
addpoints(h,datenum(t),voltage)
ax.XLim = datenum([t-seconds(15) t]);
datetick('x','keeplimits')
drawnow
stop = readDigitalPin(a,'D6');
end

Réponses (0)

Catégories

En savoir plus sur MATLAB Mobile dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by