Arduino Mega analog input has unexpected signal when connected

I have an analog control signal that varies between +12 V and -12V, so I designed a signal conditioning circuit (see attached) to split the signal into a positive half and a negative half, and reduce it to ~3V for use with an Arduino Mega to control a Sain Smart 6-axis robot arm. I am using the servo control shield sold by Sain Smart (sorry, no spec sheet since I can’t find one for it anywhere). When I run my sketch, the negative half of the signal seems to go through just fine (pin A1), but there is a constant signal of 25-53 on pin A0, which is connected to the voltage divider to reduce the +12 V signal. Where is this coming from, and how can I fix it? The input signal is either positive or negative, but can’t send both simultaneously, so if the signal is negative, there should be no voltage entering the voltage divider (verified by multimeter test), but there is still a signal on that input pin. Here is my test code.

#include <Servo.h>

//Servo myServo;

int pos = 0;

void setup() {
// put your setup code here, to run once:


pinMode(A0, INPUT);
pinMode(A1, INPUT);


void loop() {
// put your main code here, to run repeatedly:

int a0val = analogRead(A0);
Serial.println("Switch CCW: ");

int a1val = analogRead(A1);
Serial.println("Switch CW: ");


Bipolar voltages are usually read with a three-resistor voltage divider, connected to one analogue input.
One resistor from pin to ground, one resistor from pin to VCC, and one resistor from pin to the voltage to measure.
Values calculated so -12volt gives an A/D value of close to zero, +12volt close to 1023, and 0volt about 512.

The diodes will mean your output will be out by about 0.7V relative to the input voltage.

You need to scale your 24V range to 5V, which is a reduction of 4.8 to 1, and also offset it
so 0V input is 25V output. No need for any non-linear components to do this, just 3 resistors
and a fun bit of algebra.

Your fault is likely a simple wiring error or bad connection.