How do I make the Pin I select a variable
2 ビュー (過去 30 日間)
古いコメントを表示
I have this code asking me which colour I want r,g,b
(ColourAsk)
x= input('What Colour? (r,g,b)','s');
y= input('What Second Colour? (r,g,b)','s');
if x == 'r'
x='D5';
elseif x =='g'
x= 'D9';
else
x= 'D6';
end
if y == 'r'
y='D5';
elseif y =='g'
y= 'D9';
else
y= 'D6';
end
This then goes to here where it is written:
(setgrad)
writePWMDutyCycle(a,x,grad)
writePWMDutyCycle(a,y,grad2)
writePWMDutyCycle(a,z,0)
pause(0.0000000000001)
Which then goes to here to control the Pins and slowly dim/brighten the lights connected to them:
(Askgrad)
ColourAsk
grad=1;
grad2=0;
while true
%main program loop
while grad > 0.01
setgrad
grad = grad - 0.01;
grad2 = grad2 + 0.01;
end
while grad2 > 0.01
setgrad
grad = grad + 0.01;
grad2 = grad2 - 0.01;
end
end
I get an Error telling me that in setgrad I have an invalid Pin Format and that in Askgrad line 7 is an error. How do I make it so that I can use a variable to set which pin is first and second.
0 件のコメント
回答 (1 件)
Anmol Dhiman
2020 年 4 月 8 日
Hi Cole,
It is evident that the error seems to be in setgrad function. Inside setgrad, you are calling multiple functions. THe problem might be in one of those functions. I will suggest you to check what exaclty is the pin format asked for. I maybe able to help you , if you share the code for functions within setgrad.
Thanks,
Anmol Dhiman
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Arduino Hardware についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!