while loop iteration in App Designer with Arduino
Show older comments
Hi,
So I have this code
if value == 1
while value == 1
i = readDigitalPin(app.Output_Arduino,'D7');
if i == 1
app.ThrottleSW412Lamp.Color = 'g'
else
app.ThrottleSW412Lamp.Color = 'r'
end
pause(1/2)
ii = readDigitalPin(app.Output_Arduino,'D6');
if ii == 1
app.FlywheelMagPickup28Lamp.Color = 'g'
else
app.FlywheelMagPickup28Lamp.Color = 'r'
end
pause(1/2)
end
% readDitigalPin(app.Output_Arduino, 'D6')
% readDitigalPin(app.Output_Arduino, 'D5')
% readDitigalPin(app.Output_Arduino, 'D4')
% readDitigalPin(app.Output_Arduino, 'D3')
% readDitigalPin(app.Output_Arduino, 'D21')
% readDitigalPin(app.Output_Arduino, 'D20')
% readDitigalPin(app.Output_Arduino, 'D19')
% readDitigalPin(app.Output_Arduino, 'D18')
% readDitigalPin(app.Output_Arduino, 'D32')
% readDitigalPin(app.Output_Arduino, 'D31')
% readDitigalPin(app.Output_Arduino, 'D30')
% readDitigalPin(app.Output_Arduino, 'D29')
% readDitigalPin(app.Output_Arduino, 'D28')
% readDitigalPin(app.Output_Arduino, 'D27')
% readDitigalPin(app.Output_Arduino, 'D26')
% readDitigalPin(app.Output_Arduino, 'D25')
% readDitigalPin(app.Output_Arduino, 'D24')
% readDitigalPin(app.Output_Arduino, 'D13')
% readDitigalPin(app.Output_Arduino, 'D12')
end
as you can see that if I click the toggle button then the while loop starts which read the digital input from the Arduino and change the color or the lamp.
I truely believe that there has to be a way to iterate this instead of me adding the lamp and if statement for all pins. I have the pins read from excel file which I hope it would be easier since I might be able to use strcmpi and find function to fin the lamp name and then iterate it but I am not sure where to start my approach. If someone can suggest some ideas would be appreciated.
Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Startup and Shutdown 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!