I'm trying to use an Arduino to be able to convert 0-10V analog voltage into 5V PWM, using the arduino. (I know that it can be done with a simple opamp, but that's not the route I need to go with this project)
On the input, I have a voltage divider, as well as a RC high-pass filter. The output signal for some reason won't go to "0%" PWM, it just hangs at a fraction of a percentage. I've even tried multiple pull-down resistor values on the outputs, and that doesn't change the signal at all on the DSO.
That said, it sounds like the Arduino is outputting an active signal when it should be completely off, which explains why the signal cannot be pulled down to 0%.
Here is the code I'm using, please feel free to tell me what I am doing wrong!
void loop() {
newVal = analogRead(0);
if (abs(newVal - val) > 4){
val = newVal;
analogWrite(3, newVal/4);
}
newVal = analogRead(1);
if (abs(newVal - val) > 4){
val = newVal;
analogWrite(5, newVal/4);
}
newVal = analogRead(2);
if (abs(newVal - val) > 4){
val = newVal;
analogWrite(6, newVal/4);
}
newVal = analogRead(3);
if (abs(newVal - val) > 4){
val = newVal;
analogWrite(10, newVal/4);
}
newVal = analogRead(4);
if (abs(newVal - val) > 4){
val = newVal;
analogWrite(9, newVal/4);
}
newVal = analogRead(5);
if (abs(newVal - val) > 4){
val = newVal;
analogWrite(11, newVal/4);
}
}