Hello,
I am trying to control the PWM outputs of a NANO, depending on the analog input A1 (0-1023), and here is what I am trying to achieve:
All 5 PWM outputs (3,5,6,9,10) will be controlled just as simple output with two options - ON or OFF.
Between each of this steps, the software should adjust the 6th pwm output D11 from 0-255 and then the next pwm pin should be toggled ON or OFF, but once the next pin gets pulled HIGH, the 6th PWM should be turned off. With increasing the analog input, the next pwm should be pulled ON, and so on.
Pin 11 is the PWM output which will be controlled with PWM.
Once the duty cycle of pin 11 reach the maximum, then pin 3 should be switched ON and pin 11 OFF. Later on, with increasing the analog input voltage, the pin 11 should start controlling the duty cycle, and again, once it reaches it maximum of 255, the next pin ( PIN 5) should be switched ON and pin 11 OFF, and so till the end.
I've tried to use SWITCH/CASE instead of writing IF statement and to build SPAGHETTI CODE. My IDEA was to monitor only PWM OUTPUT PIN 11, and once it gets fully opened (255), then I can check which of the other position is OFF and to turn in ON.
But it seems to me that CASE function can only works with INT type of variable.
Is there any other function that someone might've used to control the above mentioned circuit?
If there are better function to use, please let me know!