Is it possible to have the PWM level increase in steps, based on a voltage range within 0-10V.
My 0-10V source increases in steps of 0.1V. Arduino is reading somewhere between the lines, thus, causing almost negligible flickering of my lights which are controlled by the PWM output. I already have a low pass RC filter, which is a 30K resistor and 4.7uf cap...nevertheless it still has a slight flicker.
For example -
0-0.1V = 1-2 (PWM - 1-2 out of the total 255)
0.1-0.2V = 3-4
ect.
This is what I am using now:
int val = 0; // variable to store the read value
void setup() {
// declare pin 9 to be an output:
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(3, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
}
void loop() {
int val = analogRead(0);
val = map(val, 0, 1023, 0, 255);
analogWrite(9, val);
val = analogRead(1);
val = map(val, 0, 1023, 0, 255);
analogWrite(10, val);
val = analogRead(2);
val = map(val, 0, 1023, 0, 255);
analogWrite(11, val);
val = analogRead(3);
val = map(val, 0, 1023, 0, 255);
analogWrite(3, val);
val = analogRead(4);
val = map(val, 0, 1023, 0, 255);
analogWrite(5, val);
val = analogRead(5);
val = map(val, 0, 1023, 0, 255);
analogWrite(6, val);
}
Thanks!