Matlab Arduino: Problem with turning on Leds in Sequence
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Juan Sanchez
am 1 Mär. 2019
Kommentiert: Juan Sanchez
am 27 Mär. 2019
Hello
Before anything I just clarify I´m still a noob in matlab. That said Im working in a script wich makes a real time adquisition of some voltage values via the Arduino A0 analog input. Depending on the voltage the leds must turn on in a sequence like a roulete (in circles). The problem is the code im using to turn on the leds
while t<inf
% All the adquisition and plotting code here
if PB(t)<PBC(t) % This is my conditional and works fine
writeDigitalPin(a,'D7',1)
pause(0.5)
writeDigitalPin(a,'D7',0)
writeDigitalPin(a,'D8',1)
pause(0.5)
writeDigitalPin(a,'D8',0)
% And so ON
end
end
The thing is that Im plotting in real time the values and the Pause inside the code is disrupting my adquisition. Is there a way to run the conditionals in paralel with the adquisition script so it doesnt disrupt the plotting? Cause another idea on the way is that when the conditional is not met again to do a "break" and stop the leds from "rotating".
I would be most grateful for any help, idea, hint or clue in this matter.
Thanks to all in advanced for the help
0 Kommentare
Akzeptierte Antwort
Abhishek Singh
am 5 Mär. 2019
Assuming if your condition works properly,
you can tackle the issue by bypassing the pause function and controlling the LED's using flags.
LED1 = false;
LED2 = false
while t<inf
% All the acquisition and plotting code here
if PB(t)<PBC(t) % This is my conditional and works fine
writeDigitalPin(a,'D7',1)
x=datetime;
% And so ON
end
if(datetime-x >1)
writeDigitalPin(a,'D7',1)
end
end
this code will bypass the pause function.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Arduino Hardware finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!