Hi,
You are having problems with your accelerometer readings, where is the link to those sensors.
I know you have 2 different accelerometers, which one do you use?
In your circuit where is it connected to the controller?
Why have you not included it in your diagram?
If you know how to connect the accelerometer, then you must have a circuit to get the connections from.
Keep the accelerometer and its wiring AWAY from the motor and its wiring.
WHY?
Because even though the motor and sensor is on different power supplies, the motor EMITTS electromagnetic interference, EMI.
The accelerometers work on very small voltages and currents, which means the EMI can cause niose problems with your sensor.
If you lift the car of the floor so its wheels spin, what sort of readings do you get from the accelerometer when you spin the wheels?
That is with the car not in motion.
Wrapping all the wires together, motor and sensor, is inviting EMI from the motor the add noise to the accelerometer signal.
What school level is this project?
Are you using one of these batteries to power the UNO?

If the sensor is the little red PCB sticky taped to the front of the car, that is not going to give you consistent readings.
The PCB MUST be properly fixed to the car so it cannot move around.
The PCB MUST be oriented so that the x,y and y axis are defined with respect to the car.
Tom... ![]()