How do I make the Pin I select a variable
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Anmol Dhiman
on 8 Apr 2020
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 Comments
See Also
Categories
Find more on MATLAB Support Package for Arduino Hardware 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!