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!