How do I run multiple "for" loops simultaenously in MATLAB?

Answers (1)

Just need one continuous loop. Just repeat commands until 3 and 5 seconds realign.
writeDigitalPin(a, 'D13', 1);
while 1
writeDigitalPin(a, 'D11', 1);
writeDigitalPin(a, 'D12', 1);
pause(0.5);
writeDigitalPin(a, 'D11', 0);
writeDigitalPin(a, 'D12', 0);
pause(2.5);
writeDigitalPin(a, 'D11', 1);
pause(0.5);
writeDigitalPin(a, 'D11', 0);
pause(1.5);
writeDigitalPin(a, 'D12', 1);
pause(0.5);
writeDigitalPin(a, 'D12', 0);
pause(0.5);
writeDigitalPin(a, 'D11', 1);
pause(0.5);
writeDigitalPin(a, 'D11', 0);
pause(2.5);
writeDigitalPin(a, 'D11', 1);
pause(0.5);
writeDigitalPin(a, 'D11', 0);
pause(0.5);
writeDigitalPin(a, 'D12', 1);
pause(0.5);
writeDigitalPin(a, 'D12', 0);
pause(1.5);
writeDigitalPin(a, 'D11', 1);
pause(0.5);
writeDigitalPin(a, 'D11', 0);
pause(2.5);
end

4 Comments

Thanks! But for this, the LED in D13 just remains on the whole time - how could I get that to blink as well?
My understanding was the third was connected to a potentiometer; therefore, the pin should be high (on) continuously and you control the led (on/off/brightness) from dialing the potentiometer.
Ah yes, it is controlled by the potentiometer, but the potentiometer controls the speed at which it blinks, or turns off and on. How do i incorporate this into the cycle? The rest of it was super helpful, thank you so much!
Did you ever find out how to incorporate it?

Sign in to comment.

Categories

Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange

Products

Release

R2019b

Asked:

on 25 Mar 2020

Edited:

on 26 Oct 2022

Community Treasure Hunt

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

Start Hunting!