My name is Janwillem90 and i'm programming my Arduino uno with simulink blocks. The goal is to control 2 PWM outputs with 1 analog input (potentiometer).
What I want: potentiometer in neutral position (digital value is about 511.5) means no PWM on both output pins. Turning the potentiometer to left (digital value decrease) the PWM output on pin 12 gets proportionally higher (from 0% to 100% dutycycle). Turning the potentiometer from neutral position to the right: digital value increase and the PWM output on pin 11 gets proportionally higher (from 0% to 100% dutycycle).
I've been thinking how to solve this. Because I'm not that skillful with this and willing to learn i thought that the following steps need to be taken:
- select output pin based on input value
- convert input value (from 0-1023 max to 0-255 max)
Can anyone please help me how to do this?