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!